-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
307 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { MNS_CONTRACTS } from '@massalabs/massa-web3'; | ||
|
||
export const MNS_CONTRACT = | ||
'AS12d2kZQYmGQRPmW7Axx5ysduAkPBR7bU86WemkkP4Lb9RSmZ13o'; | ||
// export const MNS_CONTRACT = MNS_CONTRACTS.buildnet; | ||
export const IS_MAINNET = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { | ||
getDomains, | ||
getOwner, | ||
getTokenCounter, | ||
getTotalSupply, | ||
initProvider, | ||
} from './utils'; | ||
import { MNS_CONTRACT } from './config'; | ||
|
||
const provider = await initProvider(); | ||
|
||
const owner = await getOwner(provider); | ||
console.log('Contract owner:', owner); | ||
|
||
const count = await getTokenCounter(provider, MNS_CONTRACT); | ||
console.log('COUNTER KEY:', count.toString()); | ||
|
||
const domainKeys = await getDomains(provider); | ||
console.log('Total domains:', domainKeys.length); | ||
|
||
try { | ||
const totalSupply = await getTotalSupply(provider); | ||
console.log('Total supply:', totalSupply.toString()); | ||
} catch (e) { | ||
console.log('No total supply found'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { SmartContract, Mas, Operation, rpcTypes } from '@massalabs/massa-web3'; | ||
import { | ||
getMigrateCounter, | ||
getScByteCode, | ||
getTokenCounter, | ||
initProvider, | ||
} from './utils'; | ||
import { MNS_CONTRACT } from './config'; | ||
|
||
const provider = await initProvider(); | ||
|
||
const byteCode = getScByteCode('build', 'main.wasm'); | ||
const contract = new SmartContract(provider, MNS_CONTRACT); | ||
|
||
// todo: pause contract | ||
|
||
let op: Operation; | ||
let events: rpcTypes.OutputEvents; | ||
op = await contract.call('upgradeSC', byteCode, { | ||
coins: Mas.fromString('3'), | ||
fee: Mas.fromString('0.1'), | ||
}); | ||
events = await op.getFinalEvents(); | ||
|
||
for (const event of events) { | ||
console.log('upgradeSC Events:', event.data); | ||
} | ||
|
||
console.log('upgradeSC done ! operation:', op.id); | ||
|
||
const counter = await getTokenCounter(provider, MNS_CONTRACT); | ||
let migrateCount = 0n; | ||
try { | ||
migrateCount = await getMigrateCounter(provider, MNS_CONTRACT); | ||
} catch (e) { | ||
console.log('no migrate counter found'); | ||
} | ||
|
||
while (migrateCount < counter) { | ||
console.log('migrating batch from tokenID', migrateCount.toString()); | ||
op = await contract.call('migrate', undefined, { | ||
coins: Mas.fromString('20'), | ||
fee: Mas.fromString('0.1'), | ||
}); | ||
|
||
events = await op.getFinalEvents(); | ||
|
||
for (const event of events) { | ||
console.log('migrate Events:', event.data); | ||
} | ||
migrateCount = await getMigrateCounter(provider, MNS_CONTRACT); | ||
console.log('new migrate count:', migrateCount.toString()); | ||
} | ||
|
||
// unpause contract | ||
|
||
console.log('Upgrade done ! operation:'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { SmartContract } from '@massalabs/massa-web3'; | ||
import { initProvider } from './utils'; | ||
import { MNS_CONTRACT } from './config'; | ||
|
||
const provider = await initProvider(); | ||
|
||
const contract = new SmartContract(provider, MNS_CONTRACT); | ||
|
||
const op = await contract.call('dnsLock', undefined, { coins: 100000000n }); | ||
const events = await op.getSpeculativeEvents(); | ||
|
||
for (const event of events) { | ||
console.log('pause Events:', event.data); | ||
} | ||
|
||
console.log('Contract paused ! operation:', op.id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { SmartContract } from '@massalabs/massa-web3'; | ||
import { initProvider } from './utils'; | ||
import { MNS_CONTRACT } from './config'; | ||
|
||
const provider = await initProvider(); | ||
const contract = new SmartContract(provider, MNS_CONTRACT); | ||
|
||
const op = await contract.call('dnsUnlock'); | ||
const events = await op.getSpeculativeEvents(); | ||
|
||
for (const event of events) { | ||
console.log('Unpause Events:', event.data); | ||
} | ||
|
||
console.log('Contract unpaused ! operation:', op.id); |
Oops, something went wrong.