@@ -13,6 +13,8 @@ export async function addNewSubnetwork(api: TypedApi<typeof devnet>, hotkey: Key
1313 const alice = getAliceSigner ( )
1414 const totalNetworks = await api . query . SubtensorModule . TotalNetworks . getValue ( )
1515
16+ const defaultNetworkLastLockCost = await api . query . SubtensorModule . NetworkLastLockCost . getValue ( )
17+
1618 const rateLimit = await api . query . SubtensorModule . NetworkRateLimit . getValue ( )
1719 if ( rateLimit !== BigInt ( 0 ) ) {
1820 const internalCall = api . tx . AdminUtils . sudo_set_network_rate_limit ( { rate_limit : BigInt ( 0 ) } )
@@ -28,8 +30,8 @@ export async function addNewSubnetwork(api: TypedApi<typeof devnet>, hotkey: Key
2830 // could create multiple subnetworks during retry, just return the first created one
2931 assert . ok ( newTotalNetworks > totalNetworks )
3032
31- // rewrite network last lock cost to 0, to avoid the lock cost calculation error
32- await setNetworkLastLockCost ( api )
33+ // reset network last lock cost to 0, to avoid the lock cost calculation error
34+ await setNetworkLastLockCost ( api , defaultNetworkLastLockCost )
3335 return totalNetworks
3436}
3537
@@ -404,11 +406,11 @@ export async function sendWasmContractExtrinsic(api: TypedApi<typeof devnet>, co
404406 await waitForTransactionWithRetry ( api , tx , signer )
405407}
406408
407- export async function setNetworkLastLockCost ( api : TypedApi < typeof devnet > ) {
409+ export async function setNetworkLastLockCost ( api : TypedApi < typeof devnet > , defaultNetworkLastLockCost : bigint ) {
408410 const alice = getAliceSigner ( )
409411 const key = await api . query . SubtensorModule . NetworkLastLockCost . getKey ( )
410412 const codec = await getTypedCodecs ( devnet ) ;
411- const value = codec . query . SubtensorModule . NetworkLastLockCost . value . enc ( BigInt ( 0 ) )
413+ const value = codec . query . SubtensorModule . NetworkLastLockCost . value . enc ( defaultNetworkLastLockCost )
412414 const internalCall = api . tx . System . set_storage ( {
413415 items : [ [ Binary . fromHex ( key ) , Binary . fromBytes ( value ) ] ]
414416 } )
0 commit comments