diff --git a/packages/bcp/src/cosmwasmconnection.spec.ts b/packages/bcp/src/cosmwasmconnection.spec.ts index 7c08d49c..4f4b716f 100644 --- a/packages/bcp/src/cosmwasmconnection.spec.ts +++ b/packages/bcp/src/cosmwasmconnection.spec.ts @@ -44,7 +44,7 @@ function makeRandomAddress(): Address { const faucet = { mnemonic: "economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone", - path: HdPaths.cosmos(0), + path: HdPaths.cosmosHub(0), pubkey: { algo: Algorithm.Secp256k1, data: fromBase64("A08EGB7ro1ORuFhjOnZcSgwYlpe0DSFjVNUIkNNQxwKQ") as PubkeyBytes, @@ -52,6 +52,21 @@ const faucet = { address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6" as Address, }; +/** + * We use a different test account than the faucet, since BCP errors when transactions + * with multiple messages are found. + */ +const bob = { + mnemonic: + "economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone", + path: HdPaths.cosmosHub(4), + pubkey: { + algo: Algorithm.Secp256k1, + data: fromBase64("Aum2063ub/ErUnIUB36sK55LktGUStgcbSiaAnL1wadu") as PubkeyBytes, + }, + address: "cosmos1hsm76p4ahyhl5yh3ve9ur49r5kemhp2r0dcjvx" as Address, +}; + describe("CosmWasmConnection", () => { const cosm = "COSM" as TokenTicker; const isa = "ISA" as TokenTicker; @@ -318,8 +333,8 @@ describe("CosmWasmConnection", () => { }); const profile = new UserProfile(); - const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(faucet.mnemonic)); - const sender = await profile.createIdentity(wallet.id, defaultChainId, faucet.path); + const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(bob.mnemonic)); + const sender = await profile.createIdentity(wallet.id, defaultChainId, bob.path); const senderAddress = connection.codec.identityToAddress(sender); for (const i of [0, 1]) { @@ -346,8 +361,8 @@ describe("CosmWasmConnection", () => { pendingWithoutWasmd(); const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig); const profile = new UserProfile(); - const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(faucet.mnemonic)); - const senderIdentity = await profile.createIdentity(wallet.id, defaultChainId, faucet.path); + const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(bob.mnemonic)); + const senderIdentity = await profile.createIdentity(wallet.id, defaultChainId, bob.path); const senderAddress = connection.codec.identityToAddress(senderIdentity); const unsigned = await connection.withDefaultFee({ @@ -397,8 +412,8 @@ describe("CosmWasmConnection", () => { pendingWithoutWasmd(); const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig); const profile = new UserProfile(); - const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(faucet.mnemonic)); - const senderIdentity = await profile.createIdentity(wallet.id, defaultChainId, faucet.path); + const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(bob.mnemonic)); + const senderIdentity = await profile.createIdentity(wallet.id, defaultChainId, bob.path); const senderAddress = connection.codec.identityToAddress(senderIdentity); const unsigned = await connection.withDefaultFee({ @@ -447,7 +462,7 @@ describe("CosmWasmConnection", () => { pendingWithoutWasmd(); const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig); - const results = await connection.searchTx({ sentFromOrTo: faucet.address }); + const results = await connection.searchTx({ sentFromOrTo: bob.address }); const firstSearchResult = results.find(() => true); assert(firstSearchResult, "At least one transaction sent by the faucet must be available."); assert(isConfirmedTransaction(firstSearchResult), "Transaction must be confirmed."); @@ -503,8 +518,8 @@ describe("CosmWasmConnection", () => { pendingWithoutWasmd(); const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig); const profile = new UserProfile(); - const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(faucet.mnemonic)); - const sender = await profile.createIdentity(wallet.id, defaultChainId, faucet.path); + const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(bob.mnemonic)); + const sender = await profile.createIdentity(wallet.id, defaultChainId, bob.path); const senderAddress = connection.codec.identityToAddress(sender); const unsigned = await connection.withDefaultFee({ @@ -593,8 +608,8 @@ describe("CosmWasmConnection", () => { pendingWithoutWasmd(); const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig); const profile = new UserProfile(); - const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(faucet.mnemonic)); - const sender = await profile.createIdentity(wallet.id, defaultChainId, faucet.path); + const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(bob.mnemonic)); + const sender = await profile.createIdentity(wallet.id, defaultChainId, bob.path); const senderAddress = connection.codec.identityToAddress(sender); const recipient = makeRandomAddress(); @@ -711,8 +726,8 @@ describe("CosmWasmConnection", () => { pendingWithoutWasmd(); const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig); const profile = new UserProfile(); - const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(faucet.mnemonic)); - const sender = await profile.createIdentity(wallet.id, defaultChainId, faucet.path); + const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(bob.mnemonic)); + const sender = await profile.createIdentity(wallet.id, defaultChainId, bob.path); const senderAddress = connection.codec.identityToAddress(sender); const recipient = makeRandomAddress(); @@ -923,8 +938,8 @@ describe("CosmWasmConnection", () => { const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig); const profile = new UserProfile(); - const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(faucet.mnemonic)); - const sender = await profile.createIdentity(wallet.id, defaultChainId, faucet.path); + const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(bob.mnemonic)); + const sender = await profile.createIdentity(wallet.id, defaultChainId, bob.path); // send transactions @@ -1006,8 +1021,8 @@ describe("CosmWasmConnection", () => { const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig); const profile = new UserProfile(); - const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(faucet.mnemonic)); - const sender = await profile.createIdentity(wallet.id, defaultChainId, faucet.path); + const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(bob.mnemonic)); + const sender = await profile.createIdentity(wallet.id, defaultChainId, bob.path); const recipientAddress = makeRandomAddress(); const send = await connection.withDefaultFee({ @@ -1056,8 +1071,8 @@ describe("CosmWasmConnection", () => { const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig); const profile = new UserProfile(); - const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(faucet.mnemonic)); - const sender = await profile.createIdentity(wallet.id, defaultChainId, faucet.path); + const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(bob.mnemonic)); + const sender = await profile.createIdentity(wallet.id, defaultChainId, bob.path); // send transactions diff --git a/packages/sdk/src/cosmwasmclient.searchtx.spec.ts b/packages/sdk/src/cosmwasmclient.searchtx.spec.ts index a2daa062..29de30ee 100644 --- a/packages/sdk/src/cosmwasmclient.searchtx.spec.ts +++ b/packages/sdk/src/cosmwasmclient.searchtx.spec.ts @@ -271,11 +271,13 @@ describe("CosmWasmClient.searchTx", () => { // Check basic structure of all results for (const result of results) { - const msg = fromOneElementArray(result.tx.value.msg); - assert(isMsgSend(msg), `${result.hash} (height ${result.height}) is not a bank send transaction`); - expect( - msg.value.to_address === sendSuccessful.sender || msg.value.from_address == sendSuccessful.sender, - ).toEqual(true); + const containsMsgWithSender = !!result.tx.value.msg.find( + (msg) => isMsgSend(msg) && msg.value.from_address == sendSuccessful!.sender, + ); + const containsMsgWithRecipient = !!result.tx.value.msg.find( + (msg) => isMsgSend(msg) && msg.value.to_address === sendSuccessful!.sender, + ); + expect(containsMsgWithSender || containsMsgWithRecipient).toEqual(true); } // Check details of most recent result diff --git a/packages/sdk/src/cosmwasmclient.spec.ts b/packages/sdk/src/cosmwasmclient.spec.ts index 40858956..f177424e 100644 --- a/packages/sdk/src/cosmwasmclient.spec.ts +++ b/packages/sdk/src/cosmwasmclient.spec.ts @@ -342,7 +342,7 @@ describe("CosmWasmClient", () => { decimals: 5, name: "Hash token", symbol: "HASH", - initial_balances: [ + initial_balances: jasmine.arrayContaining([ { address: faucet.address, amount: "11", @@ -355,7 +355,7 @@ describe("CosmWasmClient", () => { address: guest.address, amount: "22004000000", }, - ], + ]), }, }); }); diff --git a/scripts/wasmd/deploy_erc20.js b/scripts/wasmd/deploy_erc20.js index 84e8b6cc..c138d93f 100755 --- a/scripts/wasmd/deploy_erc20.js +++ b/scripts/wasmd/deploy_erc20.js @@ -8,7 +8,11 @@ const httpUrl = "http://localhost:1317"; const faucet = { mnemonic: "economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone", - address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", + address0: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", + address1: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5", + address2: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k", + address3: "cosmos142u9fgcjdlycfcez3lw8x6x5h7rfjlnfhpw2lx", + address4: "cosmos1hsm76p4ahyhl5yh3ve9ur49r5kemhp2r0dcjvx", }; const unused = { address: "cosmos1cjsxept9rkggzxztslae9ndgpdyt2408lk850u", @@ -28,7 +32,23 @@ const initMsgHash = { symbol: "HASH", initial_balances: [ { - address: faucet.address, + address: faucet.address0, + amount: "11", + }, + { + address: faucet.address1, + amount: "11", + }, + { + address: faucet.address2, + amount: "11", + }, + { + address: faucet.address3, + amount: "11", + }, + { + address: faucet.address4, amount: "11", }, { @@ -47,7 +67,23 @@ const initMsgIsa = { symbol: "ISA", initial_balances: [ { - address: faucet.address, + address: faucet.address0, + amount: "999999999", + }, + { + address: faucet.address1, + amount: "999999999", + }, + { + address: faucet.address2, + amount: "999999999", + }, + { + address: faucet.address3, + amount: "999999999", + }, + { + address: faucet.address4, amount: "999999999", }, { @@ -62,7 +98,23 @@ const initMsgJade = { symbol: "JADE", initial_balances: [ { - address: faucet.address, + address: faucet.address0, + amount: "189189189000000000000000000", // 189189189 JADE + }, + { + address: faucet.address1, + amount: "189189189000000000000000000", // 189189189 JADE + }, + { + address: faucet.address2, + amount: "189189189000000000000000000", // 189189189 JADE + }, + { + address: faucet.address3, + amount: "189189189000000000000000000", // 189189189 JADE + }, + { + address: faucet.address4, amount: "189189189000000000000000000", // 189189189 JADE }, { @@ -74,7 +126,7 @@ const initMsgJade = { async function main() { const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic); - const client = new SigningCosmWasmClient(httpUrl, faucet.address, (signBytes) => pen.sign(signBytes)); + const client = new SigningCosmWasmClient(httpUrl, faucet.address0, (signBytes) => pen.sign(signBytes)); const wasm = fs.readFileSync(__dirname + "/contracts/cw-erc20.wasm"); const uploadReceipt = await client.upload(wasm, codeMeta, "Upload ERC20 contract");