Skip to content

Commit

Permalink
token mutation before the rest
Browse files Browse the repository at this point in the history
  • Loading branch information
hedi-edelbloute committed Dec 7, 2023
1 parent 7606608 commit 7bb7847
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions libs/ledger-live-common/src/families/cardano/specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,47 @@ const cardano: AppSpec<Transaction> = {
genericDeviceAction: acceptTransaction,
testTimeout: 5 * 60 * 1000,
mutations: [
{
name: "move ~10% token",
maxRun: 1,
transaction: ({ account, siblings, bridge, maxSpendable }) => {
invariant(maxSpendable.gte(minSpendableRequiredForTokenTx), "balance is too low");
const sibling = pickSiblings(siblings, maxAccounts);
const recipient = sibling.freshAddress;
const transaction = bridge.createTransaction(account);

const subAccount = account.subAccounts?.find(subAccount =>
subAccount.balance.gt(1),
) as SubAccount;
invariant(subAccount, "No token account with balance");

const updates = [
{ subAccountId: subAccount.id },
{ recipient },
{
amount: new BigNumber(subAccount.balance.dividedBy(10)).dp(0, BigNumber.ROUND_CEIL),
},
];

return {
transaction,
updates,
};
},
test: ({ operation, transaction }): void => {
botTest("subOperations is defined", () => expect(operation.subOperations).toBeTruthy());

botTest("there's only one subOperation", () =>
expect(operation.subOperations?.length).toEqual(1),
);

const subOperation = operation.subOperations && operation.subOperations[0];

botTest("subOperation have correct tx amount", () =>
expect(subOperation?.value).toEqual(transaction.amount),
);
},
},
{
testDestination: genericTestDestination,
name: "move ~50%",
Expand Down Expand Up @@ -113,47 +154,6 @@ const cardano: AppSpec<Transaction> = {
);
},
},
{
name: "move ~10% token",
maxRun: 1,
transaction: ({ account, siblings, bridge, maxSpendable }) => {
invariant(maxSpendable.gte(minSpendableRequiredForTokenTx), "balance is too low");
const sibling = pickSiblings(siblings, maxAccounts);
const recipient = sibling.freshAddress;
const transaction = bridge.createTransaction(account);

const subAccount = account.subAccounts?.find(subAccount =>
subAccount.balance.gt(1),
) as SubAccount;
invariant(subAccount, "No token account with balance");

const updates = [
{ subAccountId: subAccount.id },
{ recipient },
{
amount: new BigNumber(subAccount.balance.dividedBy(10)).dp(0, BigNumber.ROUND_CEIL),
},
];

return {
transaction,
updates,
};
},
test: ({ operation, transaction }): void => {
botTest("subOperations is defined", () => expect(operation.subOperations).toBeTruthy());

botTest("there's only one subOperation", () =>
expect(operation.subOperations?.length).toEqual(1),
);

const subOperation = operation.subOperations && operation.subOperations[0];

botTest("subOperation have correct tx amount", () =>
expect(subOperation?.value).toEqual(transaction.amount),
);
},
},
{
name: "delegate to pool",
maxRun: 1,
Expand Down

1 comment on commit 7bb7847

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Bot] Testing with 'Nitrogen' ✅ 4 txs ($26.46) ⏲ 7min 20s

✅ 1 specs are successful: cardano

What is the bot and how does it work? Everything is documented here!

⚠️ 1 spec hints
  • Spec cardano:
    • mutations should define a testDestination(): move ~10% token
Details of the 4 mutations

Spec cardano (7)

Spec cardano found 7 Cardano accounts. Will use CardanoADA 6.1.2 on nanoSP 1.1.0
Cardano 1 cross: 11.005 ADA (128ops) (addr1qxef2p20nzefrlg2n3a0valzxg08hhdp0h2klye4ha4qx9twsr839ept3mchu8mqmf2mfesqewdeduhvpm4eefu4lk6qufq6ny on 1852'/1815'/0'/0/56) cardano#0 js:2:cardano:bb8ec3355bc015075ecb304f0bfc8b0dec431688938b61b2ca317c71989590bbe523dea846ca8dcd97132a58a73ee344487948951cb09b8c4f20d64dbd4c6405:cardano
Cardano 2: 4.01621 ADA (119ops) (addr1qxsp3zcjczux9xznpgsygev5aeepgn84p4hmhzvuy09qzjh4lymu3xuf47htdrl7f5s4ptpckhaf6u5lr0vk23jlsjhqlauxpu on 1852'/1815'/1'/0/48) cardano#1 js:2:cardano:761016d3b64d3ddff1f391b88a1d7ee2045fcdee5d5f635241a0f5211cd354b0f1c45abfe7e962c147de304d8dbdd18cb6bef4a52a133ef64f00793ebbc26b79:cardano
Cardano 3: 0 ADA (88ops) (addr1qye6cr0spgutyt4n0e276mtqaly0jxtjh9967zgtgumdqhhlw0zs7dasu3m0qqen37eyyssdkjy9urxr0tfm3ej2fz8sr3w2e3 on 1852'/1815'/2'/0/33) cardano#2 js:2:cardano:5600aa12b09a4b74baaf4a06a5715e7d2181e885713797fce2d93385224683632b0318a9edf19fea3d3c7e90ae6b8d2694d65be3cf26fbce7104f37512c2f8f3:cardano
Cardano 4: 15.7331 ADA (117ops) (addr1q936ux3krcqenss26ktnxsd59gjtsquv376gnlf27d5aka8ey3teslxzrx7fdxn36e80yzync6j4e0zx33gq0tzlaskqsv96qw on 1852'/1815'/3'/0/55) cardano#3 js:2:cardano:58a62f7388caa92bd71bb09aeddfe04b4088eda52b855d358c4321d5d4db62059d119f9740b2f030317bf13bb0ae8ba651eb6e5e19b6437941c197172586f7b0:cardano
Cardano 5: 0 ADA (111ops) (addr1q8srgqm3halzpxll0q5fxvawp59gmewkgpxcyf3435k22xn87wxdp5wvfrzupdvpsha3w66pamgjm9dffqdkzy0a02yq33767t on 1852'/1815'/4'/0/55) cardano#4 js:2:cardano:a1be5fea2977156fff143da65a47622f1d02e245b41377b91adff868c8f30c1c404891e1367eefac31c6f1f2ec4c349a5411e720c5506c32d07d945631131241:cardano
Cardano 6: 28.7412 ADA (93ops) (addr1q9dxrnj34cclclnvphkh379kzfe47lprev73d3rehfkzd6dszad2pxt2prragz995z3z0msrdfuycwm8nt8d7x3s0ffsc84gnj on 1852'/1815'/5'/0/58) cardano#5 js:2:cardano:2cfb2158a01a610c7ee92e819c7c6fb06c946eb9aaaa85c04d3f0d1d54edc2b9c32bbdbab432c93491cf0d42e01bb57a716039b4219dbfd8fbbeeaebae2561ec:cardano
Cardano 7: 0 ADA (0ops) (addr1qy39gylyelv2zly254mx8hcpgd7v4r8695u70l5q24pnu6vnhrutx2jy94jetmv2j5klhj6qpfwz3fukp200c69shnpsnrhq6x on 1852'/1815'/6'/0/0) cardano#6 js:2:cardano:96c1570c627d1acf38c6e9003e7e2a681e5782e10c838aef30324a081399df5e3ba9448bb614970fb21f7e464e71985e63929f84913b3ee9786405d56ee4e95b:cardano
necessary accounts resynced in 6ms
▬ CardanoADA 6.1.2 on nanoSP 1.1.0
→ FROM Cardano 1 cross: 11.005 ADA (128ops) (addr1qxef2p20nzefrlg2n3a0valzxg08hhdp0h2klye4ha4qx9twsr839ept3mchu8mqmf2mfesqewdeduhvpm4eefu4lk6qufq6ny on 1852'/1815'/0'/0/56) cardano#0 js:2:cardano:bb8ec3355bc015075ecb304f0bfc8b0dec431688938b61b2ca317c71989590bbe523dea846ca8dcd97132a58a73ee344487948951cb09b8c4f20d64dbd4c6405:cardano (! sum of ops 8.98126 ADA) Total 0 ADA rewards available.
  TokenAccount Hosky Inu: 10 HI (1 ops)
max spendable ~9.48444
★ using mutation 'move ~10% token'
→ TO Cardano 6: 28.7412 ADA (93ops) (addr1q9dxrnj34cclclnvphkh379kzfe47lprev73d3rehfkzd6dszad2pxt2prragz995z3z0msrdfuycwm8nt8d7x3s0ffsc84gnj on 1852'/1815'/5'/0/58) cardano#5 js:2:cardano:2cfb2158a01a610c7ee92e819c7c6fb06c946eb9aaaa85c04d3f0d1d54edc2b9c32bbdbab432c93491cf0d42e01bb57a716039b4219dbfd8fbbeeaebae2561ec:cardano
✔️ transaction 
  SEND  1 HI
TO addr1q9dxrnj34cclclnvphkh379kzfe47lprev73d3rehfkzd6dszad2pxt2prragz995z3z0msrdfuycwm8nt8d7x3s0ffsc84gnj
STATUS (32ms)
  amount: 1 HI
  estimated fees: 0.177425 ADA
  total spent: 1 HI
errors: 
errors: 
✔️ has been signed! (12.7s) 
✔️ broadcasted! (298ms) optimistic operation: 
  -1.522223 ADA      OUT        78df47a468de9c7a849928af86b37e52e45b7c786c1c5db9e8abd1789020f378 2023-12-07T15:05
    -1 HI            OUT        
✔️ operation confirmed (80.6s): 
  -1.522223 ADA      OUT        78df47a468de9c7a849928af86b37e52e45b7c786c1c5db9e8abd1789020f378 2023-12-07T15:06
    -1 HI            OUT        
✔️ Cardano 1 cross: 9.48281 ADA (129ops) (addr1qxef2p20nzefrlg2n3a0valzxg08hhdp0h2klye4ha4qx9twsr839ept3mchu8mqmf2mfesqewdeduhvpm4eefu4lk6qufq6ny on 1852'/1815'/0'/0/56) cardano#0 js:2:cardano:bb8ec3355bc015075ecb304f0bfc8b0dec431688938b61b2ca317c71989590bbe523dea846ca8dcd97132a58a73ee344487948951cb09b8c4f20d64dbd4c6405:cardano (! sum of ops 7.459037 ADA) Total 0 ADA rewards available.
  TokenAccount Hosky Inu: 9 HI (2 ops)(in 80.6s)

necessary accounts resynced in 582ms
▬ CardanoADA 6.1.2 on nanoSP 1.1.0
→ FROM Cardano 2: 4.01621 ADA (119ops) (addr1qxsp3zcjczux9xznpgsygev5aeepgn84p4hmhzvuy09qzjh4lymu3xuf47htdrl7f5s4ptpckhaf6u5lr0vk23jlsjhqlauxpu on 1852'/1815'/1'/0/48) cardano#1 js:2:cardano:761016d3b64d3ddff1f391b88a1d7ee2045fcdee5d5f635241a0f5211cd354b0f1c45abfe7e962c147de304d8dbdd18cb6bef4a52a133ef64f00793ebbc26b79:cardano (! sum of ops 4.007952 ADA) 4.016212 ADA delegated to Cardanoscan Pool 1 (CSN1) 7df262feae9201d1b2e32d4c825ca91b29fbafb2b8e556f6efb7f549. Total 0 ADA rewards available.

max spendable ~3.85093
★ using mutation 'undelegate'
✔️ transaction 
  UNDELEGATE 
STATUS (30ms)
  amount: 0 ADA
  estimated fees: 0.171309 ADA
  total spent: 0.171309 ADA
errors: 
errors: 
✔️ has been signed! (13.1s) 
✔️ broadcasted! (279ms) optimistic operation: 
  -0.171309 ADA      UNDELEGATE 9dbcf8ae333d9b2e6e31f449f17c23ccd4ebb281baa5e5f44b806fed4f779027 2023-12-07T15:06
✔️ operation confirmed (90.7s): 
  -0.171309 ADA      UNDELEGATE 9dbcf8ae333d9b2e6e31f449f17c23ccd4ebb281baa5e5f44b806fed4f779027 2023-12-07T15:07
✔️ Cardano 2: 5.8449 ADA (120ops) (addr1qxsp3zcjczux9xznpgsygev5aeepgn84p4hmhzvuy09qzjh4lymu3xuf47htdrl7f5s4ptpckhaf6u5lr0vk23jlsjhqlauxpu on 1852'/1815'/1'/0/48) cardano#1 js:2:cardano:761016d3b64d3ddff1f391b88a1d7ee2045fcdee5d5f635241a0f5211cd354b0f1c45abfe7e962c147de304d8dbdd18cb6bef4a52a133ef64f00793ebbc26b79:cardano (! sum of ops 3.836643 ADA) Total 0 ADA rewards available.
(in 90.7s)

necessary accounts resynced in 0.24ms
▬ CardanoADA 6.1.2 on nanoSP 1.1.0
→ FROM Cardano 4: 15.7331 ADA (117ops) (addr1q936ux3krcqenss26ktnxsd59gjtsquv376gnlf27d5aka8ey3teslxzrx7fdxn36e80yzync6j4e0zx33gq0tzlaskqsv96qw on 1852'/1815'/3'/0/55) cardano#3 js:2:cardano:58a62f7388caa92bd71bb09aeddfe04b4088eda52b855d358c4321d5d4db62059d119f9740b2f030317bf13bb0ae8ba651eb6e5e19b6437941c197172586f7b0:cardano (! sum of ops 9.720259 ADA) Total 0 ADA rewards available.
  TokenAccount Hosky Inu: 1 HI (1 ops)
max spendable ~14.2065
★ using mutation 'send max'
→ TO Cardano 6: 30.086 ADA (94ops) (addr1qyd0ahnxq42drccq6l075pq435whkcvz85g6rhlvxhf5psdszad2pxt2prragz995z3z0msrdfuycwm8nt8d7x3s0ffslqgce8 on 1852'/1815'/5'/0/59) cardano#5 js:2:cardano:2cfb2158a01a610c7ee92e819c7c6fb06c946eb9aaaa85c04d3f0d1d54edc2b9c32bbdbab432c93491cf0d42e01bb57a716039b4219dbfd8fbbeeaebae2561ec:cardano
✔️ transaction 
  SEND MAX
TO addr1qyd0ahnxq42drccq6l075pq435whkcvz85g6rhlvxhf5psdszad2pxt2prragz995z3z0msrdfuycwm8nt8d7x3s0ffslqgce8
STATUS (68ms)
  amount: 14.206527 ADA
  estimated fees: 0.181825 ADA
  total spent: 14.388352 ADA
errors: 
errors: 
✔️ has been signed! (13.7s) 
✔️ broadcasted! (332ms) optimistic operation: 
  -14.388352 ADA     OUT        182e7f549acd6682aed4428b66b9ad84802916e08f72aeafef3ab4405d2deeb7 2023-12-07T15:08
✔️ operation confirmed (80.6s): 
  -14.388352 ADA     OUT        182e7f549acd6682aed4428b66b9ad84802916e08f72aeafef3ab4405d2deeb7 2023-12-07T15:09
✔️ Cardano 4: 1.34479 ADA (118ops) (addr1q936ux3krcqenss26ktnxsd59gjtsquv376gnlf27d5aka8ey3teslxzrx7fdxn36e80yzync6j4e0zx33gq0tzlaskqsv96qw on 1852'/1815'/3'/0/55) cardano#3 js:2:cardano:58a62f7388caa92bd71bb09aeddfe04b4088eda52b855d358c4321d5d4db62059d119f9740b2f030317bf13bb0ae8ba651eb6e5e19b6437941c197172586f7b0:cardano (! sum of ops -4.668093 ADA) Total 0 ADA rewards available.
  TokenAccount Hosky Inu: 1 HI (1 ops)(in 80.6s)
✔️ destination operation 
  +14.206527 ADA     IN         182e7f549acd6682aed4428b66b9ad84802916e08f72aeafef3ab4405d2deeb7 2023-12-07T15:09
(in 11s)

necessary accounts resynced in 0.32ms
▬ CardanoADA 6.1.2 on nanoSP 1.1.0
→ FROM Cardano 6: 44.2925 ADA (95ops) (addr1qyfxyhx2h8xhs6z3l88ragwj7eh24rv36a57kxcs3fv5424szad2pxt2prragz995z3z0msrdfuycwm8nt8d7x3s0ffs4e4x8h on 1852'/1815'/5'/0/60) cardano#5 js:2:cardano:2cfb2158a01a610c7ee92e819c7c6fb06c946eb9aaaa85c04d3f0d1d54edc2b9c32bbdbab432c93491cf0d42e01bb57a716039b4219dbfd8fbbeeaebae2561ec:cardano (! sum of ops 37.964193 ADA) Total 0 ADA rewards available.
  TokenAccount Hosky Inu: 3 HI (3 ops)
max spendable ~42.7418
★ using mutation 'move ~50%'
→ TO Cardano 2: 5.8449 ADA (120ops) (addr1qxsp3zcjczux9xznpgsygev5aeepgn84p4hmhzvuy09qzjh4lymu3xuf47htdrl7f5s4ptpckhaf6u5lr0vk23jlsjhqlauxpu on 1852'/1815'/1'/0/48) cardano#1 js:2:cardano:761016d3b64d3ddff1f391b88a1d7ee2045fcdee5d5f635241a0f5211cd354b0f1c45abfe7e962c147de304d8dbdd18cb6bef4a52a133ef64f00793ebbc26b79:cardano
✔️ transaction 
  SEND  22.146278 ADA
TO addr1qxsp3zcjczux9xznpgsygev5aeepgn84p4hmhzvuy09qzjh4lymu3xuf47htdrl7f5s4ptpckhaf6u5lr0vk23jlsjhqlauxpu
STATUS (87ms)
  amount: 22.146278 ADA
  estimated fees: 0.178569 ADA
  total spent: 22.324847 ADA
errors: 
errors: 
✔️ has been signed! (11.4s) 
✔️ broadcasted! (290ms) optimistic operation: 
  -22.324847 ADA     OUT        48d8f47bdf5f6d82cf11138c6ca1b850092c1e07066527e775dda63c1c01ba07 2023-12-07T15:10
✔️ operation confirmed (50.7s): 
  -22.324847 ADA     OUT        48d8f47bdf5f6d82cf11138c6ca1b850092c1e07066527e775dda63c1c01ba07 2023-12-07T15:10
✔️ Cardano 6: 21.9677 ADA (96ops) (addr1qyfxyhx2h8xhs6z3l88ragwj7eh24rv36a57kxcs3fv5424szad2pxt2prragz995z3z0msrdfuycwm8nt8d7x3s0ffs4e4x8h on 1852'/1815'/5'/0/60) cardano#5 js:2:cardano:2cfb2158a01a610c7ee92e819c7c6fb06c946eb9aaaa85c04d3f0d1d54edc2b9c32bbdbab432c93491cf0d42e01bb57a716039b4219dbfd8fbbeeaebae2561ec:cardano (! sum of ops 15.639346 ADA) Total 0 ADA rewards available.
  TokenAccount Hosky Inu: 3 HI (3 ops)(in 50.7s)
✔️ destination operation 
  +22.146278 ADA     IN         48d8f47bdf5f6d82cf11138c6ca1b850092c1e07066527e775dda63c1c01ba07 2023-12-07T15:10
(in 10.7s)


Details of the 2 uncovered mutations

Spec cardano (2)

  • delegate to pool: balance is too low (3)
  • redelegate to pool: balance is too low (3)
Portfolio ($26.46) – Details of the 1 currencies
Spec (accounts) State Remaining Runs (est) funds?
cardano (7) 663 ops (+7), 55.4612 ADA ($26.46) ⚠️ 49 addr1qxef2p20nzefrlg2n3a0valzxg08hhdp0h2klye4ha4qx9twsr839ept3mchu8mqmf2mfesqewdeduhvpm4eefu4lk6qufq6ny
Cardano 1 cross: 9.48281 ADA (129ops) (addr1qxef2p20nzefrlg2n3a0valzxg08hhdp0h2klye4ha4qx9twsr839ept3mchu8mqmf2mfesqewdeduhvpm4eefu4lk6qufq6ny on 1852'/1815'/0'/0/56) cardano#0 js:2:cardano:bb8ec3355bc015075ecb304f0bfc8b0dec431688938b61b2ca317c71989590bbe523dea846ca8dcd97132a58a73ee344487948951cb09b8c4f20d64dbd4c6405:cardano
Cardano 2: 27.9911 ADA (121ops) (addr1q86a6n3a59x6z92t3zvyt6fscu00gcewq27sa5ym0kdty3h4lymu3xuf47htdrl7f5s4ptpckhaf6u5lr0vk23jlsjhqt62fq8 on 1852'/1815'/1'/0/49) cardano#1 js:2:cardano:761016d3b64d3ddff1f391b88a1d7ee2045fcdee5d5f635241a0f5211cd354b0f1c45abfe7e962c147de304d8dbdd18cb6bef4a52a133ef64f00793ebbc26b79:cardano
Cardano 3: 0 ADA (88ops) (addr1qye6cr0spgutyt4n0e276mtqaly0jxtjh9967zgtgumdqhhlw0zs7dasu3m0qqen37eyyssdkjy9urxr0tfm3ej2fz8sr3w2e3 on 1852'/1815'/2'/0/33) cardano#2 js:2:cardano:5600aa12b09a4b74baaf4a06a5715e7d2181e885713797fce2d93385224683632b0318a9edf19fea3d3c7e90ae6b8d2694d65be3cf26fbce7104f37512c2f8f3:cardano
Cardano 4: 1.34479 ADA (118ops) (addr1q936ux3krcqenss26ktnxsd59gjtsquv376gnlf27d5aka8ey3teslxzrx7fdxn36e80yzync6j4e0zx33gq0tzlaskqsv96qw on 1852'/1815'/3'/0/55) cardano#3 js:2:cardano:58a62f7388caa92bd71bb09aeddfe04b4088eda52b855d358c4321d5d4db62059d119f9740b2f030317bf13bb0ae8ba651eb6e5e19b6437941c197172586f7b0:cardano
Cardano 5: 0 ADA (111ops) (addr1q8srgqm3halzpxll0q5fxvawp59gmewkgpxcyf3435k22xn87wxdp5wvfrzupdvpsha3w66pamgjm9dffqdkzy0a02yq33767t on 1852'/1815'/4'/0/55) cardano#4 js:2:cardano:a1be5fea2977156fff143da65a47622f1d02e245b41377b91adff868c8f30c1c404891e1367eefac31c6f1f2ec4c349a5411e720c5506c32d07d945631131241:cardano
Cardano 6: 21.9677 ADA (96ops) (addr1qyfxyhx2h8xhs6z3l88ragwj7eh24rv36a57kxcs3fv5424szad2pxt2prragz995z3z0msrdfuycwm8nt8d7x3s0ffs4e4x8h on 1852'/1815'/5'/0/60) cardano#5 js:2:cardano:2cfb2158a01a610c7ee92e819c7c6fb06c946eb9aaaa85c04d3f0d1d54edc2b9c32bbdbab432c93491cf0d42e01bb57a716039b4219dbfd8fbbeeaebae2561ec:cardano
Cardano 7: 0 ADA (0ops) (addr1qy39gylyelv2zly254mx8hcpgd7v4r8695u70l5q24pnu6vnhrutx2jy94jetmv2j5klhj6qpfwz3fukp200c69shnpsnrhq6x on 1852'/1815'/6'/0/0) cardano#6 js:2:cardano:96c1570c627d1acf38c6e9003e7e2a681e5782e10c838aef30324a081399df5e3ba9448bb614970fb21f7e464e71985e63929f84913b3ee9786405d56ee4e95b:cardano
Performance ⏲ 7min 20s

Time spent for each spec: (total across mutations)

Spec (accounts) preload scan re-sync tx status sign op broadcast test destination test
TOTAL 1.43ms 56.4s 590ms 217ms 50.9s 1199ms 5min 3s 21.8s
cardano (6) 1.43ms 56.4s 590ms 217ms 50.9s 1199ms 5min 3s 21.8s

What is the bot and how does it work? Everything is documented here!

Please sign in to comment.