Skip to content

Commit

Permalink
chore(deps): update sdk-next to 14
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Feb 11, 2025
1 parent e5ef078 commit 7e94e9f
Show file tree
Hide file tree
Showing 13 changed files with 749 additions and 321 deletions.
60 changes: 32 additions & 28 deletions docker-compose/init-state.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import { execSync } from 'child_process';
import {
Node, AeSdk, MemoryAccount, generateSaveHDWalletFromSeed, getSaveHDWalletAccounts,
encode, Encoding,
Node, AeSdk, MemoryAccount, AccountMnemonicFactory, encode, Encoding, Name,
} from '@aeternity/aepp-sdk-next';
import { mnemonicToSeed } from '@aeternity/bip39';

// TODO: remove after merging https://github.com/aeternity/ae_mdw/issues/1758
try {
Expand All @@ -22,18 +20,17 @@ await (async function rollbackToFirstBlock() {
if (status !== 200) throw new Error(`Unexpected status code: ${status}`);
})();

const onNode = new Node('http://localhost:3013');
const aeSdk = new AeSdk({
nodes: [{ name: 'testnet', instance: new Node('http://localhost:3013') }],
nodes: [{ name: 'testnet', instance: onNode }],
accounts: [
new MemoryAccount('9ebd7beda0c79af72a42ece3821a56eff16359b6df376cf049aee995565f022f840c974b97164776454ba119d84edc4d6058a8dec92b6edc578ab2d30b4c4200'),
new MemoryAccount('sk_2CuofqWZHrABCrM7GY95YSQn8PyFvKQadnvFnpwhjUnDCFAWmf'),
],
});

const seed = mnemonicToSeed('cross cat upper state flame wire inner betray almost party agree endorse');
const wallet = generateSaveHDWalletFromSeed(seed, '');
const [{ secretKey }, { secretKey: secretKey2 }] = getSaveHDWalletAccounts(wallet, '', 2);
const account1 = new MemoryAccount(secretKey);
const account2 = new MemoryAccount(secretKey2);
const factory = new AccountMnemonicFactory('cross cat upper state flame wire inner betray almost party agree endorse');
const account1 = await factory.initialize(0);
const account2 = await factory.initialize(1);

await aeSdk.spend(200e18, account1.address);
await aeSdk.spend(100e18, account2.address);
Expand All @@ -47,31 +44,38 @@ await (async function prepareTransactionHistory() {
})();

await (async function prepareNames() {
await aeSdk.aensClaim('engine.chain', 0);
await aeSdk.aensBid('engine.chain', 60e18, { onAccount: account1 });
await aeSdk.aensBid('engine.chain', 65e18);
await aeSdk.aensClaim('visual.chain', 0);
await aeSdk.aensBid('visual.chain', 60e18, { onAccount: account1 });
await aeSdk.aensClaim('inspector.chain', 0);
await aeSdk.aensClaim('мир.chain', 0);
await aeSdk.aensClaim('understanding.chain', 0, { onAccount: account1 });
await aeSdk.aensClaim('entertainment.chain', 0, { onAccount: account2 });
await aeSdk.aensUpdate('entertainment.chain', {
const engine = new Name('engine.chain', aeSdk.getContext());
await engine.claim();
await engine.bid(60e18, { onAccount: account1 });
await engine.bid(65e18);

const visual = new Name('visual.chain', aeSdk.getContext());
await visual.claim();
await visual.bid(60e18, { onAccount: account1 });

await (new Name('inspector.chain', aeSdk.getContext())).claim();

await (new Name('мир.chain', aeSdk.getContext())).claim();

await (new Name('understanding.chain', { onNode, onAccount: account1 })).claim();

const entertainment = new Name('entertainment.chain', { onNode, onAccount: account2 });
await entertainment.claim();
await entertainment.update({
'account_pubkey': account2.address,
'contract_pubkey': account1.address.replace('ak_', 'ct_'),
'second account': account1.address,
'raw': encode(Buffer.from('test'), Encoding.Bytearray),
}, { onAccount: account2 });
});
console.log('Names ready');
})();

await (async function wallet2() {
const seed = mnemonicToSeed('sun dish cousin double youth year path fix away pig spring upset');
const wallet = generateSaveHDWalletFromSeed(seed, '');
const [{ secretKey }, { publicKey: publicKey2 }] = getSaveHDWalletAccounts(wallet, '', 2);
const acc = new MemoryAccount(secretKey);
await aeSdk.spend(100e18, acc.address);
await aeSdk.spend(100e18, publicKey2);
await aeSdk.aensClaim('investigation.chain', 0, { onAccount: acc });
const factory = new AccountMnemonicFactory('sun dish cousin double youth year path fix away pig spring upset');
const acc1 = await factory.initialize(0);
const acc2 = await factory.initialize(1);
await aeSdk.spend(100e18, acc1.address);
await aeSdk.spend(100e18, acc2.address);
await (new Name('investigation.chain', { onNode, onAccount: acc1 })).claim();
console.log('Wallet 2 ready');
})();
Loading

0 comments on commit 7e94e9f

Please sign in to comment.