Skip to content

Commit

Permalink
Merge pull request #2 from Momentum-Safe/ref/refactor-applications
Browse files Browse the repository at this point in the history
Fix sort key issue and add test
  • Loading branch information
AaricChen authored Feb 10, 2024
2 parents daecfec + 971f4ae commit f1989aa
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
],
"dependencies": {
"buffer": "^6.0.3",
"sort-keys": "^5.0.0"
"sort-keys-recursive": "^2.1.10"
},
"devDependencies": {
"@msafe/sui3-utils": "^3.1.18",
Expand Down
2 changes: 1 addition & 1 deletion src/apps/msafe-core/intention.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TransactionType } from '@msafe/sui3-utils';
import { SuiClient } from '@mysten/sui.js/client';
import { TransactionBlock } from '@mysten/sui.js/transactions';
import { WalletAccount } from '@mysten/wallet-standard';
import sortKeys from 'sort-keys';
import sortKeys from 'sort-keys-recursive';

import { TransactionIntention } from '@/apps/interface';

Expand Down
12 changes: 11 additions & 1 deletion test/core.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TransactionType } from '@msafe/sui3-utils';

import { CoinTransferIntentionData } from '@/apps/msafe-core/coin-transfer';
import { CoinTransferIntention, CoinTransferIntentionData } from '@/apps/msafe-core/coin-transfer';
import { appHelpers } from '@/index';

import { Account, Client } from './config';
Expand All @@ -25,4 +25,14 @@ describe('MSafe Core Wallet', () => {
expect(res.blockData.version).toBe(1);
expect(res.blockData.sender).toBe('0x0df172b18d30935ad68b2f9d6180e5adcf8edfd7df874852817002e6eccada66');
});

it('Test intention serialization', () => {
const intention = CoinTransferIntention.fromData({
recipient: 'a',
coinType: 'b',
amount: '100',
});

expect(intention.serialize()).toBe('{"amount":"100","coinType":"b","recipient":"a"}');
});
});
31 changes: 22 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2743,10 +2743,10 @@ is-path-inside@^3.0.3:
resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283"
integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==

is-plain-obj@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-4.1.0.tgz#d65025edec3657ce032fd7db63c97883eaed71f0"
integrity sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==
is-plain-obj@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287"
integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==

is-property@^1.0.2:
version "1.0.2"
Expand Down Expand Up @@ -3300,6 +3300,11 @@ keyv@^4.5.3:
dependencies:
json-buffer "3.0.1"

kind-of@~6.0.2:
version "6.0.3"
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==

kleur@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"
Expand Down Expand Up @@ -4002,12 +4007,20 @@ slash@^3.0.0:
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==

sort-keys@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-5.0.0.tgz#5d775f8ae93ecc29bc7312bbf3acac4e36e3c446"
integrity sha512-Pdz01AvCAottHTPQGzndktFNdbRA75BgOfeT1hH+AMnJFv8lynkPi42rfeEhpx1saTEI3YNMWxfqu0sFD1G8pw==
sort-keys-recursive@^2.1.10:
version "2.1.10"
resolved "https://registry.yarnpkg.com/sort-keys-recursive/-/sort-keys-recursive-2.1.10.tgz#df5e22d3f3ff0427fdc4a088f16c37c1839456b8"
integrity sha512-yRLJbEER/PjU7hSRwXvP+NyXiORufu8rbSbp+3wFRuJZXoi/AhuKczbjuipqn7Le0SsTXK4VUeri2+Ni6WS8Hg==
dependencies:
kind-of "~6.0.2"
sort-keys "~4.2.0"

sort-keys@~4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-4.2.0.tgz#6b7638cee42c506fff8c1cecde7376d21315be18"
integrity sha512-aUYIEU/UviqPgc8mHR6IW1EGxkAXpeRETYcrzg8cLAvUPZcpAlleSXHV2mY7G12GphSH6Gzv+4MMVSSkbdteHg==
dependencies:
is-plain-obj "^4.0.0"
is-plain-obj "^2.0.0"

[email protected]:
version "0.5.13"
Expand Down

0 comments on commit f1989aa

Please sign in to comment.