From 40a0974ce4a42b28de2a09a1b876ca9b94bb449f Mon Sep 17 00:00:00 2001 From: Mykhailo Baraniak Date: Mon, 9 Dec 2024 13:16:43 +0100 Subject: [PATCH 1/3] refactor: remove CI files --- .github/workflows/borsh.yml | 21 --------------------- .travis.yml | 11 ----------- CNAME | 1 - 3 files changed, 33 deletions(-) delete mode 100644 .github/workflows/borsh.yml delete mode 100644 .travis.yml delete mode 100644 CNAME diff --git a/.github/workflows/borsh.yml b/.github/workflows/borsh.yml deleted file mode 100644 index e60ca75c1..000000000 --- a/.github/workflows/borsh.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Borsh Tests -on: [push] -jobs: - unit-tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: '14' - - run: yarn install - - run: yarn test - prettier: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: '14' - - run: yarn install - - run: yarn pretty:check diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7083439ba..000000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: node_js -node_js: - - 12 - -before_script: - - "curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install.sh | sudo bash" - -script: - - fossa init - - fossa analyze --server-scan - - fossa test diff --git a/CNAME b/CNAME deleted file mode 100644 index d3294114f..000000000 --- a/CNAME +++ /dev/null @@ -1 +0,0 @@ -borsh.io \ No newline at end of file From 6a4ec5edf19c7bf26166635fd20ab095c104066d Mon Sep 17 00:00:00 2001 From: Mykhailo Baraniak Date: Mon, 9 Dec 2024 13:21:11 +0100 Subject: [PATCH 2/3] refactor: update package.json --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 1574f25cd..367eb21f7 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/near/borsh-js.git" + "url": "git+https://github.com/ExodusMovement/borsh-js.git" }, "keywords": [ "serializer", @@ -35,12 +35,12 @@ "consistency", "deterministic" ], - "author": "Near Inc", + "author": "Exodus Movement, Inc.", "license": "Apache-2.0", "bugs": { - "url": "https://github.com/near/borsh-js/issues" + "url": "https://github.com/ExodusMovement/borsh-js/issues" }, - "homepage": "https://github.com/near/borsh-js#readme", + "homepage": "https://github.com/ExodusMovement/borsh-js#readme", "devDependencies": { "@types/babel__core": "^7.1.2", "@types/babel__template": "^7.0.2", From 3f12b6f5e12eea43525dd18c700e467e10a76e54 Mon Sep 17 00:00:00 2001 From: Mykhailo Baraniak Date: Mon, 9 Dec 2024 13:23:13 +0100 Subject: [PATCH 3/3] refactor: remove fuzzing test corpus --- borsh-ts/test/fuzz/borsh-roundtrip.js | 19 -- ...37181f6340b5b269b7faee05d97fe65b1ab91cd171 | Bin 160 -> 0 bytes ...06f0a57fc7b5f2cb5c08ba00ff900a79ebd0637da7 | Bin 163 -> 0 bytes ...b3ffb19fcaf35deef41f8c084726c5aac5a4551696 | Bin 168 -> 0 bytes ...28d3381c64c61654579dc455a9e5ccaa54bc093721 | Bin 160 -> 0 bytes ...4ba237896a8ee4dffebd27b65c8101a1d8897d6409 | Bin 164 -> 0 bytes ...a2de056c34c40850bbe61b9ebc82cf48365484f4fc | Bin 155 -> 0 bytes ...38baae9bddbd620d018f803540e09ac1bc82ec3a6c | Bin 155 -> 0 bytes ...58a5c55d25830a8efffb9e8661a81e2db3584ca512 | Bin 155 -> 0 bytes ...137cf3e506f550fcfa19363050d1e4917250d83d32 | Bin 168 -> 0 bytes ...5107e67373646fe7c5370030819ccc13990375ca73 | Bin 160 -> 0 bytes ...bdaf44b17f2cd52501f1b5567ed05406163cf96fef | Bin 155 -> 0 bytes ...11e27c119009d0fcccbdddd5fe669c8c02bf04f7dd | Bin 170 -> 0 bytes ...58136c1f2dbd9ed3cad450556faf7b18db4184b42e | Bin 155 -> 0 bytes ...6d6e8ee36819bb22b7304f4e23f61d189a6c221f92 | Bin 164 -> 0 bytes ...2a1be308f7d25d21f81622a7ffc7da3733c03eb572 | Bin 160 -> 0 bytes ...f8e5b7e1c9962a36c8489ada9cb0f798c1ec967eb7 | Bin 109 -> 0 bytes ...b510fffc51f5c78078db2a2fb5cf19b0bd840291ee | Bin 155 -> 0 bytes ...f841050f0b2d78fa519ac76f178db0757d1bd3e96e | Bin 174 -> 0 bytes ...f981ab86d16876888bb7ba665637c5717c0a8916b2 | Bin 155 -> 0 bytes .../test/fuzz/transaction-example/enums.d.ts | 7 - .../test/fuzz/transaction-example/enums.js | 22 -- .../fuzz/transaction-example/key_pair.d.ts | 61 ----- .../test/fuzz/transaction-example/key_pair.js | 125 ---------- .../fuzz/transaction-example/serialize.d.ts | 41 --- .../fuzz/transaction-example/serialize.js | 16 -- .../test/fuzz/transaction-example/signer.d.ts | 63 ----- .../test/fuzz/transaction-example/signer.js | 82 ------ .../fuzz/transaction-example/transaction.d.ts | 106 -------- .../fuzz/transaction-example/transaction.js | 234 ------------------ package.json | 2 - 31 files changed, 778 deletions(-) delete mode 100644 borsh-ts/test/fuzz/borsh-roundtrip.js delete mode 100644 borsh-ts/test/fuzz/corpus/004b705c22403d1c22ceab37181f6340b5b269b7faee05d97fe65b1ab91cd171 delete mode 100644 borsh-ts/test/fuzz/corpus/25b2da453a8cb0d574d31a06f0a57fc7b5f2cb5c08ba00ff900a79ebd0637da7 delete mode 100644 borsh-ts/test/fuzz/corpus/2f6f8117189cb82e111a13b3ffb19fcaf35deef41f8c084726c5aac5a4551696 delete mode 100644 borsh-ts/test/fuzz/corpus/4eb3f263ac0d9bac83d67e28d3381c64c61654579dc455a9e5ccaa54bc093721 delete mode 100644 borsh-ts/test/fuzz/corpus/5a0ac0f8936af102c2ea974ba237896a8ee4dffebd27b65c8101a1d8897d6409 delete mode 100644 borsh-ts/test/fuzz/corpus/67fc403d488908e0a27d74a2de056c34c40850bbe61b9ebc82cf48365484f4fc delete mode 100644 borsh-ts/test/fuzz/corpus/7fa19d2ffc291390ebe8a238baae9bddbd620d018f803540e09ac1bc82ec3a6c delete mode 100644 borsh-ts/test/fuzz/corpus/824d229c23c200a937bcd558a5c55d25830a8efffb9e8661a81e2db3584ca512 delete mode 100644 borsh-ts/test/fuzz/corpus/9d6a787b7d95c13bb67d02137cf3e506f550fcfa19363050d1e4917250d83d32 delete mode 100644 borsh-ts/test/fuzz/corpus/a330e2fd8d25278e3d28205107e67373646fe7c5370030819ccc13990375ca73 delete mode 100644 borsh-ts/test/fuzz/corpus/a53d5be4493c7cccab1d70bdaf44b17f2cd52501f1b5567ed05406163cf96fef delete mode 100644 borsh-ts/test/fuzz/corpus/b7361e727623b1cdafda1411e27c119009d0fcccbdddd5fe669c8c02bf04f7dd delete mode 100644 borsh-ts/test/fuzz/corpus/b98f80e8a618038000215158136c1f2dbd9ed3cad450556faf7b18db4184b42e delete mode 100644 borsh-ts/test/fuzz/corpus/bec080831059d96afd82176d6e8ee36819bb22b7304f4e23f61d189a6c221f92 delete mode 100644 borsh-ts/test/fuzz/corpus/cf94b13d93b7accf950d3d2a1be308f7d25d21f81622a7ffc7da3733c03eb572 delete mode 100644 borsh-ts/test/fuzz/corpus/d2897d4dc13f861fb5e7caf8e5b7e1c9962a36c8489ada9cb0f798c1ec967eb7 delete mode 100644 borsh-ts/test/fuzz/corpus/dfbc571f6a049f8f66f2fcb510fffc51f5c78078db2a2fb5cf19b0bd840291ee delete mode 100644 borsh-ts/test/fuzz/corpus/e08ccfae0c2fd6432c8e1bf841050f0b2d78fa519ac76f178db0757d1bd3e96e delete mode 100644 borsh-ts/test/fuzz/corpus/ecd71b60d1820dbbcb06d1f981ab86d16876888bb7ba665637c5717c0a8916b2 delete mode 100644 borsh-ts/test/fuzz/transaction-example/enums.d.ts delete mode 100644 borsh-ts/test/fuzz/transaction-example/enums.js delete mode 100644 borsh-ts/test/fuzz/transaction-example/key_pair.d.ts delete mode 100644 borsh-ts/test/fuzz/transaction-example/key_pair.js delete mode 100644 borsh-ts/test/fuzz/transaction-example/serialize.d.ts delete mode 100644 borsh-ts/test/fuzz/transaction-example/serialize.js delete mode 100644 borsh-ts/test/fuzz/transaction-example/signer.d.ts delete mode 100644 borsh-ts/test/fuzz/transaction-example/signer.js delete mode 100644 borsh-ts/test/fuzz/transaction-example/transaction.d.ts delete mode 100644 borsh-ts/test/fuzz/transaction-example/transaction.js diff --git a/borsh-ts/test/fuzz/borsh-roundtrip.js b/borsh-ts/test/fuzz/borsh-roundtrip.js deleted file mode 100644 index f790375d4..000000000 --- a/borsh-ts/test/fuzz/borsh-roundtrip.js +++ /dev/null @@ -1,19 +0,0 @@ -const borsh = require('../../../lib/index.js'); -const transaction = require('./transaction-example/transaction'); - -exports.fuzz = input => { - try { - const deserialized = borsh.deserialize(transaction.SCHEMA, transaction.Transaction, input); - const serialized = borsh.serialize(transaction.SCHEMA, deserialized); - if (!serialized.equals(input)) { - console.log(`Mismatching output:\n${serialized.toString('hex')}\nand input:\n${input.toString('hex')}`); - throw new Error('Mismatching input and output'); - } - } catch (e) { - if (e instanceof borsh.BorshError) { - // Do nothing - } else { - throw e; - } - } -}; \ No newline at end of file diff --git a/borsh-ts/test/fuzz/corpus/004b705c22403d1c22ceab37181f6340b5b269b7faee05d97fe65b1ab91cd171 b/borsh-ts/test/fuzz/corpus/004b705c22403d1c22ceab37181f6340b5b269b7faee05d97fe65b1ab91cd171 deleted file mode 100644 index fcfea9a29697dc2d94ce838889c3553ef75f0a19..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 160 zcmZQz0D{Vx?OVSVnLc;ASUO?Sher&B3(jhP=9ABmZQx6v94FAh2vP(DVnAG6Qks&P zuUl50?3-F#oLFj^YGRn{`@Xrlxz%|lzj4F*J}nFJyWja=PGdCPwDwX|`fM%6w;%(U ixPU}rN(xw8dMY=NSFKc%T2Z28rKD8b&>{yEzytt67B2As diff --git a/borsh-ts/test/fuzz/corpus/25b2da453a8cb0d574d31a06f0a57fc7b5f2cb5c08ba00ff900a79ebd0637da7 b/borsh-ts/test/fuzz/corpus/25b2da453a8cb0d574d31a06f0a57fc7b5f2cb5c08ba00ff900a79ebd0637da7 deleted file mode 100644 index 3e55b9a7f45b59ea242c6cdbd0dee8f1d4104891..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 163 zcmZQz0D{Vx?OVSVDLr?(SUO?Sher&B3(jhP=9ABmZQx6v94FSn$iPsoRFYaz0#XbF z0zh0`Qks&PuUl50TxywWVwmguzPY-&)p;hral`sPEer9x-}zroV>I2g_EJ>(Y%RvO lKrMGh!{2>`26FGm0X diff --git a/borsh-ts/test/fuzz/corpus/2f6f8117189cb82e111a13b3ffb19fcaf35deef41f8c084726c5aac5a4551696 b/borsh-ts/test/fuzz/corpus/2f6f8117189cb82e111a13b3ffb19fcaf35deef41f8c084726c5aac5a4551696 deleted file mode 100644 index 9f09c84d6a89cc14a382a943328c8fd347767bd0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 168 zcmZQz0D{Vx?OVSVDLr?(SUO?Sher&B3(jhP=9ABmZQx6v94FSn$iPsoRFYaz0#y3| zhy{SSxTG{CGher?Jh{{|)xe&f~n?K=b8M*4eR@~OvLYg=YKhk(QMP&OHt{wwHV)m3}E5{ k5{W4(zNy8i3><1 nrlk0$78fU`!*!-|1BI)VN>VFIl&qALY8zVQfC5M$62b-mG&nH7 diff --git a/borsh-ts/test/fuzz/corpus/67fc403d488908e0a27d74a2de056c34c40850bbe61b9ebc82cf48365484f4fc b/borsh-ts/test/fuzz/corpus/67fc403d488908e0a27d74a2de056c34c40850bbe61b9ebc82cf48365484f4fc deleted file mode 100644 index 77435fee1f33b572c943a5939a934f1d0d8d127a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 155 zcmZQz0D{Vx?OVSVDLr?(SUO?Sher&B3(jhP=9ABmZQx6v94FSn2vP(D0zh0`Qks&P zuUl50TxywWVwmguzPY-&)p;hral`sPEer9x-}zroV>I2g_EJ>(Y%RvOAiYdnKq4_E g#W%IMI59ny8_26xDoL#bI0}5aQ01<&Ki3>=; cc(^b diff --git a/borsh-ts/test/fuzz/corpus/824d229c23c200a937bcd558a5c55d25830a8efffb9e8661a81e2db3584ca512 b/borsh-ts/test/fuzz/corpus/824d229c23c200a937bcd558a5c55d25830a8efffb9e8661a81e2db3584ca512 deleted file mode 100644 index f7c9ac58b4c75f59f733b9ea2d09e7f718b858af..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 155 zcmZQz0D{Vx?OVSVDLr?(SUO?Sher&B3(jhP=9ABmZQx6v94FSn2vWr0#vlMBi%UvV zGV^uI%9BeiQ%wwWecv}%H@7;^i3><1 irlk0$78fU`r*Z>%)k-C)6(vemN=mg2Epk8sOaK5dAuTHa diff --git a/borsh-ts/test/fuzz/corpus/9d6a787b7d95c13bb67d02137cf3e506f550fcfa19363050d1e4917250d83d32 b/borsh-ts/test/fuzz/corpus/9d6a787b7d95c13bb67d02137cf3e506f550fcfa19363050d1e4917250d83d32 deleted file mode 100644 index 630b94ad0b64803456fe83b17806ed1c307dc17f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 168 zcmZQz0D{Vx?OVSVDLr?(SUO?Sher&B3(jhP=9ABmZQx6v94FSn$iPsoRFYaz0#XbF z0zh0`Qks&PuUl50TxywWVwjutzPY-&)p;hral`sPEer9x-}zroV>I2g_EJ>(Y%RvO oKre&f~n?K=b8M*4eR@~EX41A=YKhk(QMP&OHt{wwHV)m3}E5{ k5{W4(zNy8ecv}%H@7;^7e+ZXmB(sU)?cM9E4?skWg-4k!QyzZe*R2nqm>U@)}+ diff --git a/borsh-ts/test/fuzz/corpus/b7361e727623b1cdafda1411e27c119009d0fcccbdddd5fe669c8c02bf04f7dd b/borsh-ts/test/fuzz/corpus/b7361e727623b1cdafda1411e27c119009d0fcccbdddd5fe669c8c02bf04f7dd deleted file mode 100644 index d0f9ae0329c0ca85e30e55962b0d41ade18cc9cd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 170 zcmZQz0D{Vx?OVSVDLr?(SUO?Sher&B3(jhP=9ABmZQx6v94FSn2vWr0#vlMBi%UvV zGF|F#&3%48U$?A0xzsY%#4y+QeRFkltMg2L2{g&QxxoaJ5oNYDI~Xm6B3zLyH_x00~4w*Z^FmG_L>v diff --git a/borsh-ts/test/fuzz/corpus/b98f80e8a618038000215158136c1f2dbd9ed3cad450556faf7b18db4184b42e b/borsh-ts/test/fuzz/corpus/b98f80e8a618038000215158136c1f2dbd9ed3cad450556faf7b18db4184b42e deleted file mode 100644 index 0181e35d13a2d5fe0a567dd7e7fa99296ad0245a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 155 zcmZQz0D{Vx?OVSVDLr?(SUO?Sher&B3(jhP=9ABmZQx6v94FSn2vWqr$RGeDi%UvV zGV^uI%9BeiQ%wwWecv}%H@7;^i3><1 irlk0$78fU`r*Z>%)k-C)6(vemN=mg2Epk8sOaK4|-YmHQ diff --git a/borsh-ts/test/fuzz/corpus/bec080831059d96afd82176d6e8ee36819bb22b7304f4e23f61d189a6c221f92 b/borsh-ts/test/fuzz/corpus/bec080831059d96afd82176d6e8ee36819bb22b7304f4e23f61d189a6c221f92 deleted file mode 100644 index b04b3f05854aa3d7637fae48b14de189d4a50cb6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 164 zcmZQz0D{Vx?OVSVnLc+)ES)gv!y|^m1!uKC^T}t(Ht?lSjuYr$1StXnF(583DNV`D z*DWhg_DwA=zF2CRYGRn{`@Xrlxz%|lzj4F*KCPG27)v*;y%d!`TZZv1NG}r?kVs5P o0qICgFHeSQO63L$S1XmIR+K1NDJj)9w8#MkV3q-ykw6Rt0QN{QR{#J2 diff --git a/borsh-ts/test/fuzz/corpus/cf94b13d93b7accf950d3d2a1be308f7d25d21f81622a7ffc7da3733c03eb572 b/borsh-ts/test/fuzz/corpus/cf94b13d93b7accf950d3d2a1be308f7d25d21f81622a7ffc7da3733c03eb572 deleted file mode 100644 index 5ade500ec2b0052071865b84132da79f2fe64e4a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 160 zcmZQz0D{Vx?OVSVnLc;ASUO?Sher&B3(jhP=9ABmZQx6v94FAh$WRMX#vlg7#U-UF znfbb9<;ibTi;ELWEmKVlbA8`8S2wph&*V35Sl_2*A%6Ee|I2BNrkmDYib|iY#pufj m)X2mIBob3nd_mgMQ@Me>YNe9YiV`I&B_)Q27CE2*CIA46HZJi1 diff --git a/borsh-ts/test/fuzz/corpus/d2897d4dc13f861fb5e7caf8e5b7e1c9962a36c8489ada9cb0f798c1ec967eb7 b/borsh-ts/test/fuzz/corpus/d2897d4dc13f861fb5e7caf8e5b7e1c9962a36c8489ada9cb0f798c1ec967eb7 deleted file mode 100644 index 86c116b9414d856cb4b88364dfc37699623ba442..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 109 zcmZQz0D{Vx?OVSVDLr?(SUO?Sher&B3(jhP=9ABmZQx6v94FSn2vP(D0zh0`Qks&P wuUl50TxywWVwmguzPY-&)p;hral`sPEer9x-}zroV>I2g_EJi3><1 lrlk0$78fU`r*Z>%)k-C)6(vemN=mg2Epk8sG>~dy2mt&aEnolu diff --git a/borsh-ts/test/fuzz/corpus/e08ccfae0c2fd6432c8e1bf841050f0b2d78fa519ac76f178db0757d1bd3e96e b/borsh-ts/test/fuzz/corpus/e08ccfae0c2fd6432c8e1bf841050f0b2d78fa519ac76f178db0757d1bd3e96e deleted file mode 100644 index 212ab60fe57278568a39376e388dee96da8129a1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 174 zcmZQz0D{Vx?OVSVDLr?(SUO?Sher&B3(jhP=9ABmZQx6v94FSn2vWr0#vlMBi%UvV zGV^uI%9BeiznB>2`o3?jZf2kA@&=}hGY3Rf$Yq*jzDSt%*iHnhkA1z-T-7NAHZL=*tFkT+%k diff --git a/borsh-ts/test/fuzz/corpus/ecd71b60d1820dbbcb06d1f981ab86d16876888bb7ba665637c5717c0a8916b2 b/borsh-ts/test/fuzz/corpus/ecd71b60d1820dbbcb06d1f981ab86d16876888bb7ba665637c5717c0a8916b2 deleted file mode 100644 index 82dc8f8e8159af961fe9392b5612129507348459..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 155 zcmZQz0D{Vx?OVSVDLr?(SUO>nz$1pj1!uKC^T}t(Ht?lSjuY!(1Sw*0V-Nt6#U-UF znfbb9<;kU%A508$ecv}%H@7;^i3><1 irlk0$78fU`r*Z>%)k-C)6(vemN=mg2Epk8sOaK7uJS^4# diff --git a/borsh-ts/test/fuzz/transaction-example/enums.d.ts b/borsh-ts/test/fuzz/transaction-example/enums.d.ts deleted file mode 100644 index 4d0a3dae9..000000000 --- a/borsh-ts/test/fuzz/transaction-example/enums.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export declare abstract class Enum { - enum: string; - constructor(properties: any); -} -export declare abstract class Assignable { - constructor(properties: any); -} diff --git a/borsh-ts/test/fuzz/transaction-example/enums.js b/borsh-ts/test/fuzz/transaction-example/enums.js deleted file mode 100644 index 68d950cb3..000000000 --- a/borsh-ts/test/fuzz/transaction-example/enums.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -class Enum { - constructor(properties) { - if (Object.keys(properties).length !== 1) { - throw new Error('Enum can only take single value'); - } - Object.keys(properties).map((key) => { - this[key] = properties[key]; - this.enum = key; - }); - } -} -exports.Enum = Enum; -class Assignable { - constructor(properties) { - Object.keys(properties).map((key) => { - this[key] = properties[key]; - }); - } -} -exports.Assignable = Assignable; diff --git a/borsh-ts/test/fuzz/transaction-example/key_pair.d.ts b/borsh-ts/test/fuzz/transaction-example/key_pair.d.ts deleted file mode 100644 index cf7a473d2..000000000 --- a/borsh-ts/test/fuzz/transaction-example/key_pair.d.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { Assignable } from './enums'; -export declare type Arrayish = string | ArrayLike; -export interface Signature { - signature: Uint8Array; - publicKey: PublicKey; -} -/** All supported key types */ -export declare enum KeyType { - ED25519 = 0 -} -/** - * PublicKey representation that has type and bytes of the key. - */ -export declare class PublicKey extends Assignable { - keyType: KeyType; - data: Uint8Array; - static from(value: string | PublicKey): PublicKey; - static fromString(encodedKey: string): PublicKey; - toString(): string; -} -export declare abstract class KeyPair { - abstract sign(message: Uint8Array): Signature; - abstract verify(message: Uint8Array, signature: Uint8Array): boolean; - abstract toString(): string; - abstract getPublicKey(): PublicKey; - /** - * @param curve Name of elliptical curve, case-insensitive - * @returns Random KeyPair based on the curve - */ - static fromRandom(curve: string): KeyPair; - static fromString(encodedKey: string): KeyPair; -} -/** - * This class provides key pair functionality for Ed25519 curve: - * generating key pairs, encoding key pairs, signing and verifying. - */ -export declare class KeyPairEd25519 extends KeyPair { - readonly publicKey: PublicKey; - readonly secretKey: string; - /** - * Construct an instance of key pair given a secret key. - * It's generally assumed that these are encoded in base58. - * @param {string} secretKey - */ - constructor(secretKey: string); - /** - * Generate a new random keypair. - * @example - * const keyRandom = KeyPair.fromRandom(); - * keyRandom.publicKey - * // returns [PUBLIC_KEY] - * - * keyRandom.secretKey - * // returns [SECRET_KEY] - */ - static fromRandom(): KeyPairEd25519; - sign(message: Uint8Array): Signature; - verify(message: Uint8Array, signature: Uint8Array): boolean; - toString(): string; - getPublicKey(): PublicKey; -} diff --git a/borsh-ts/test/fuzz/transaction-example/key_pair.js b/borsh-ts/test/fuzz/transaction-example/key_pair.js deleted file mode 100644 index 16182d5e0..000000000 --- a/borsh-ts/test/fuzz/transaction-example/key_pair.js +++ /dev/null @@ -1,125 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const tweetnacl_1 = __importDefault(require("tweetnacl")); -const serialize_1 = require("./serialize"); -const enums_1 = require("./enums"); -/** All supported key types */ -var KeyType; -(function (KeyType) { - KeyType[KeyType["ED25519"] = 0] = "ED25519"; -})(KeyType = exports.KeyType || (exports.KeyType = {})); -function key_type_to_str(keyType) { - switch (keyType) { - case KeyType.ED25519: return 'ed25519'; - default: throw new Error(`Unknown key type ${keyType}`); - } -} -function str_to_key_type(keyType) { - switch (keyType.toLowerCase()) { - case 'ed25519': return KeyType.ED25519; - default: throw new Error(`Unknown key type ${keyType}`); - } -} -/** - * PublicKey representation that has type and bytes of the key. - */ -class PublicKey extends enums_1.Assignable { - static from(value) { - if (typeof value === 'string') { - return PublicKey.fromString(value); - } - return value; - } - static fromString(encodedKey) { - const parts = encodedKey.split(':'); - if (parts.length === 1) { - return new PublicKey({ keyType: KeyType.ED25519, data: serialize_1.base_decode(parts[0]) }); - } - else if (parts.length === 2) { - return new PublicKey({ keyType: str_to_key_type(parts[0]), data: serialize_1.base_decode(parts[1]) }); - } - else { - throw new Error('Invalid encoded key format, must be :'); - } - } - toString() { - return `${key_type_to_str(this.keyType)}:${serialize_1.base_encode(this.data)}`; - } -} -exports.PublicKey = PublicKey; -class KeyPair { - /** - * @param curve Name of elliptical curve, case-insensitive - * @returns Random KeyPair based on the curve - */ - static fromRandom(curve) { - switch (curve.toUpperCase()) { - case 'ED25519': return KeyPairEd25519.fromRandom(); - default: throw new Error(`Unknown curve ${curve}`); - } - } - static fromString(encodedKey) { - const parts = encodedKey.split(':'); - if (parts.length === 1) { - return new KeyPairEd25519(parts[0]); - } - else if (parts.length === 2) { - switch (parts[0].toUpperCase()) { - case 'ED25519': return new KeyPairEd25519(parts[1]); - default: throw new Error(`Unknown curve: ${parts[0]}`); - } - } - else { - throw new Error('Invalid encoded key format, must be :'); - } - } -} -exports.KeyPair = KeyPair; -/** - * This class provides key pair functionality for Ed25519 curve: - * generating key pairs, encoding key pairs, signing and verifying. - */ -class KeyPairEd25519 extends KeyPair { - /** - * Construct an instance of key pair given a secret key. - * It's generally assumed that these are encoded in base58. - * @param {string} secretKey - */ - constructor(secretKey) { - super(); - const keyPair = tweetnacl_1.default.sign.keyPair.fromSecretKey(serialize_1.base_decode(secretKey)); - this.publicKey = new PublicKey({ keyType: KeyType.ED25519, data: keyPair.publicKey }); - this.secretKey = secretKey; - } - /** - * Generate a new random keypair. - * @example - * const keyRandom = KeyPair.fromRandom(); - * keyRandom.publicKey - * // returns [PUBLIC_KEY] - * - * keyRandom.secretKey - * // returns [SECRET_KEY] - */ - static fromRandom() { - const newKeyPair = tweetnacl_1.default.sign.keyPair(); - return new KeyPairEd25519(serialize_1.base_encode(newKeyPair.secretKey)); - } - sign(message) { - const signature = tweetnacl_1.default.sign.detached(message, serialize_1.base_decode(this.secretKey)); - return { signature, publicKey: this.publicKey }; - } - verify(message, signature) { - return tweetnacl_1.default.sign.detached.verify(message, signature, this.publicKey.data); - } - toString() { - return `ed25519:${this.secretKey}`; - } - getPublicKey() { - return this.publicKey; - } -} -exports.KeyPairEd25519 = KeyPairEd25519; diff --git a/borsh-ts/test/fuzz/transaction-example/serialize.d.ts b/borsh-ts/test/fuzz/transaction-example/serialize.d.ts deleted file mode 100644 index 6db96b581..000000000 --- a/borsh-ts/test/fuzz/transaction-example/serialize.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/// -import BN from 'bn.js'; -export declare function base_encode(value: Uint8Array | string): string; -export declare function base_decode(value: string): Uint8Array; -export declare type Schema = Map; -export declare class BorshError extends Error { - originalMessage: string; - fieldPath: string[]; - constructor(message: string); - addToFieldPath(fieldName: string): void; -} -export declare class BinaryWriter { - buf: Buffer; - length: number; - constructor(); - maybe_resize(): void; - write_u8(value: number): void; - write_u32(value: number): void; - write_u64(value: BN): void; - write_u128(value: BN): void; - private write_buffer; - write_string(str: string): void; - write_fixed_array(array: Uint8Array): void; - write_array(array: any[], fn: any): void; - toArray(): Uint8Array; -} -export declare class BinaryReader { - buf: Buffer; - offset: number; - constructor(buf: Buffer); - read_u8(): number; - read_u32(): number; - read_u64(): BN; - read_u128(): BN; - private read_buffer; - read_string(): string; - read_fixed_array(len: number): Uint8Array; - read_array(fn: any): any[]; -} -export declare function serialize(schema: Schema, obj: any): Uint8Array; -export declare function deserialize(schema: Schema, classType: any, buffer: Buffer): any; diff --git a/borsh-ts/test/fuzz/transaction-example/serialize.js b/borsh-ts/test/fuzz/transaction-example/serialize.js deleted file mode 100644 index 8084fc574..000000000 --- a/borsh-ts/test/fuzz/transaction-example/serialize.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -const bs58_1 = __importDefault(require("bs58")); -function base_encode(value) { - if (typeof (value) === 'string') { - value = Buffer.from(value, 'utf8'); - } - return bs58_1.default.encode(Buffer.from(value)); -} -exports.base_encode = base_encode; -function base_decode(value) { - return Buffer.from(bs58_1.default.decode(value)); -} -exports.base_decode = base_decode; diff --git a/borsh-ts/test/fuzz/transaction-example/signer.d.ts b/borsh-ts/test/fuzz/transaction-example/signer.d.ts deleted file mode 100644 index 36775b637..000000000 --- a/borsh-ts/test/fuzz/transaction-example/signer.d.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { Signature, KeyPair, PublicKey } from './key_pair'; -import { KeyStore } from './key_stores'; -/** - * General signing interface, can be used for in memory signing, RPC singing, external wallet, HSM, etc. - */ -export declare abstract class Signer { - /** - * Creates new key and returns public key. - */ - abstract createKey(accountId: string, networkId?: string): Promise; - /** - * Returns public key for given account / network. - * @param accountId accountId to retrieve from. - * @param networkId The targeted network. (ex. default, betanet, etc…) - */ - abstract getPublicKey(accountId?: string, networkId?: string): Promise; - /** - * Signs given message, by first hashing with sha256. - * @param message message to sign. - * @param accountId accountId to use for signing. - * @param networkId The targeted network. (ex. default, betanet, etc…) - */ - abstract signMessage(message: Uint8Array, accountId?: string, networkId?: string): Promise; -} -/** - * Signs using in memory key store. - */ -export declare class InMemorySigner extends Signer { - readonly keyStore: KeyStore; - constructor(keyStore: KeyStore); - /** - * Creates a single account Signer instance with account, network and keyPair provided. - * - * Intended to be useful for temporary keys (e.g. claiming a Linkdrop). - * - * @param networkId The targeted network. (ex. default, betanet, etc…) - * @param accountId The NEAR account to assign the key pair to - * @param keyPair The keyPair to use for signing - */ - static fromKeyPair(networkId: string, accountId: string, keyPair: KeyPair): Promise; - /** - * Creates a public key for the account given - * @param accountId The NEAR account to assign a public key to - * @param networkId The targeted network. (ex. default, betanet, etc…) - * @returns {Promise} - */ - createKey(accountId: string, networkId: string): Promise; - /** - * Gets the existing public key for a given account - * @param accountId The NEAR account to assign a public key to - * @param networkId The targeted network. (ex. default, betanet, etc…) - * @returns {Promise} Returns the public key or null if not found - */ - getPublicKey(accountId?: string, networkId?: string): Promise; - /** - * @param message A message to be signed, typically a serialized transaction - * @param accountId the NEAR account signing the message - * @param networkId The targeted network. (ex. default, betanet, etc…) - * @returns {Promise} - */ - signMessage(message: Uint8Array, accountId?: string, networkId?: string): Promise; - toString(): string; -} diff --git a/borsh-ts/test/fuzz/transaction-example/signer.js b/borsh-ts/test/fuzz/transaction-example/signer.js deleted file mode 100644 index 933db3add..000000000 --- a/borsh-ts/test/fuzz/transaction-example/signer.js +++ /dev/null @@ -1,82 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const js_sha256_1 = __importDefault(require("js-sha256")); -const key_pair_1 = require("./key_pair"); -const key_stores_1 = require("./key_stores"); -/** - * General signing interface, can be used for in memory signing, RPC singing, external wallet, HSM, etc. - */ -class Signer { -} -exports.Signer = Signer; -/** - * Signs using in memory key store. - */ -class InMemorySigner extends Signer { - constructor(keyStore) { - super(); - this.keyStore = keyStore; - } - /** - * Creates a single account Signer instance with account, network and keyPair provided. - * - * Intended to be useful for temporary keys (e.g. claiming a Linkdrop). - * - * @param networkId The targeted network. (ex. default, betanet, etc…) - * @param accountId The NEAR account to assign the key pair to - * @param keyPair The keyPair to use for signing - */ - static async fromKeyPair(networkId, accountId, keyPair) { - const keyStore = new key_stores_1.InMemoryKeyStore(); - await keyStore.setKey(networkId, accountId, keyPair); - return new InMemorySigner(keyStore); - } - /** - * Creates a public key for the account given - * @param accountId The NEAR account to assign a public key to - * @param networkId The targeted network. (ex. default, betanet, etc…) - * @returns {Promise} - */ - async createKey(accountId, networkId) { - const keyPair = key_pair_1.KeyPair.fromRandom('ed25519'); - await this.keyStore.setKey(networkId, accountId, keyPair); - return keyPair.getPublicKey(); - } - /** - * Gets the existing public key for a given account - * @param accountId The NEAR account to assign a public key to - * @param networkId The targeted network. (ex. default, betanet, etc…) - * @returns {Promise} Returns the public key or null if not found - */ - async getPublicKey(accountId, networkId) { - const keyPair = await this.keyStore.getKey(networkId, accountId); - if (keyPair === null) { - return null; - } - return keyPair.getPublicKey(); - } - /** - * @param message A message to be signed, typically a serialized transaction - * @param accountId the NEAR account signing the message - * @param networkId The targeted network. (ex. default, betanet, etc…) - * @returns {Promise} - */ - async signMessage(message, accountId, networkId) { - const hash = new Uint8Array(js_sha256_1.default.sha256.array(message)); - if (!accountId) { - throw new Error('InMemorySigner requires provided account id'); - } - const keyPair = await this.keyStore.getKey(networkId, accountId); - if (keyPair === null) { - throw new Error(`Key for ${accountId} not found in ${networkId}`); - } - return keyPair.sign(hash); - } - toString() { - return `InMemorySigner(${this.keyStore})`; - } -} -exports.InMemorySigner = InMemorySigner; diff --git a/borsh-ts/test/fuzz/transaction-example/transaction.d.ts b/borsh-ts/test/fuzz/transaction-example/transaction.d.ts deleted file mode 100644 index bedf27f31..000000000 --- a/borsh-ts/test/fuzz/transaction-example/transaction.d.ts +++ /dev/null @@ -1,106 +0,0 @@ -/// -import BN from 'bn.js'; -import { Enum, Assignable } from './enums'; -import { KeyType, PublicKey } from './key_pair'; -import { Signer } from './signer'; -export declare class FunctionCallPermission extends Assignable { - allowance?: BN; - receiverId: string; - methodNames: string[]; -} -export declare class FullAccessPermission extends Assignable { -} -export declare class AccessKeyPermission extends Enum { - functionCall: FunctionCallPermission; - fullAccess: FullAccessPermission; -} -export declare class AccessKey extends Assignable { - nonce: number; - permission: AccessKeyPermission; -} -export declare function fullAccessKey(): AccessKey; -export declare function functionCallAccessKey(receiverId: string, methodNames: string[], allowance?: BN): AccessKey; -export declare class IAction extends Assignable { -} -export declare class CreateAccount extends IAction { -} -export declare class DeployContract extends IAction { - code: Uint8Array; -} -export declare class FunctionCall extends IAction { - methodName: string; - args: Uint8Array; - gas: BN; - deposit: BN; -} -export declare class Transfer extends IAction { - deposit: BN; -} -export declare class Stake extends IAction { - stake: BN; - publicKey: PublicKey; -} -export declare class AddKey extends IAction { - publicKey: PublicKey; - accessKey: AccessKey; -} -export declare class DeleteKey extends IAction { - publicKey: PublicKey; -} -export declare class DeleteAccount extends IAction { - beneficiaryId: string; -} -export declare function createAccount(): Action; -export declare function deployContract(code: Uint8Array): Action; -/** - * Constructs {@link Action} instance representing contract method call. - * - * @param methodName the name of the method to call - * @param args arguments to pass to method. Can be either plain JS object which gets serialized as JSON automatically - * or `Uint8Array` instance which represents bytes passed as is. - * @param gas max amount of gas that method call can use - * @param deposit amount of NEAR (in yoctoNEAR) to send together with the call - */ -export declare function functionCall(methodName: string, args: Uint8Array | object, gas: BN, deposit: BN): Action; -export declare function transfer(deposit: BN): Action; -export declare function stake(stake: BN, publicKey: PublicKey): Action; -export declare function addKey(publicKey: PublicKey, accessKey: AccessKey): Action; -export declare function deleteKey(publicKey: PublicKey): Action; -export declare function deleteAccount(beneficiaryId: string): Action; -export declare class Signature extends Assignable { - keyType: KeyType; - data: Uint8Array; -} -export declare class Transaction extends Assignable { - signerId: string; - publicKey: PublicKey; - nonce: number; - receiverId: string; - actions: Action[]; - blockHash: Uint8Array; - encode(): Uint8Array; - static decode(bytes: Buffer): Transaction; -} -export declare class SignedTransaction extends Assignable { - transaction: Transaction; - signature: Signature; - encode(): Uint8Array; - static decode(bytes: Buffer): SignedTransaction; -} -/** - * Contains a list of the valid transaction Actions available with this API - */ -export declare class Action extends Enum { - createAccount: CreateAccount; - deployContract: DeployContract; - functionCall: FunctionCall; - transfer: Transfer; - stake: Stake; - addKey: AddKey; - deleteKey: DeleteKey; - deleteAccount: DeleteAccount; -} -export declare const SCHEMA: Map; -export declare function createTransaction(signerId: string, publicKey: PublicKey, receiverId: string, nonce: number, actions: Action[], blockHash: Uint8Array): Transaction; -export declare function signTransaction(transaction: Transaction, signer: Signer, accountId?: string, networkId?: string): Promise<[Uint8Array, SignedTransaction]>; -export declare function signTransaction(receiverId: string, nonce: number, actions: Action[], blockHash: Uint8Array, signer: Signer, accountId?: string, networkId?: string): Promise<[Uint8Array, SignedTransaction]>; diff --git a/borsh-ts/test/fuzz/transaction-example/transaction.js b/borsh-ts/test/fuzz/transaction-example/transaction.js deleted file mode 100644 index a70bcaba7..000000000 --- a/borsh-ts/test/fuzz/transaction-example/transaction.js +++ /dev/null @@ -1,234 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const js_sha256_1 = __importDefault(require("js-sha256")); -const enums_1 = require("./enums"); -const serialize_1 = require("./serialize"); -const key_pair_1 = require("./key_pair"); -class FunctionCallPermission extends enums_1.Assignable { -} -exports.FunctionCallPermission = FunctionCallPermission; -class FullAccessPermission extends enums_1.Assignable { -} -exports.FullAccessPermission = FullAccessPermission; -class AccessKeyPermission extends enums_1.Enum { -} -exports.AccessKeyPermission = AccessKeyPermission; -class AccessKey extends enums_1.Assignable { -} -exports.AccessKey = AccessKey; -function fullAccessKey() { - return new AccessKey({ nonce: 0, permission: new AccessKeyPermission({ fullAccess: new FullAccessPermission({}) }) }); -} -exports.fullAccessKey = fullAccessKey; -function functionCallAccessKey(receiverId, methodNames, allowance) { - return new AccessKey({ nonce: 0, permission: new AccessKeyPermission({ functionCall: new FunctionCallPermission({ receiverId, allowance, methodNames }) }) }); -} -exports.functionCallAccessKey = functionCallAccessKey; -class IAction extends enums_1.Assignable { -} -exports.IAction = IAction; -class CreateAccount extends IAction { -} -exports.CreateAccount = CreateAccount; -class DeployContract extends IAction { -} -exports.DeployContract = DeployContract; -class FunctionCall extends IAction { -} -exports.FunctionCall = FunctionCall; -class Transfer extends IAction { -} -exports.Transfer = Transfer; -class Stake extends IAction { -} -exports.Stake = Stake; -class AddKey extends IAction { -} -exports.AddKey = AddKey; -class DeleteKey extends IAction { -} -exports.DeleteKey = DeleteKey; -class DeleteAccount extends IAction { -} -exports.DeleteAccount = DeleteAccount; -function createAccount() { - return new Action({ createAccount: new CreateAccount({}) }); -} -exports.createAccount = createAccount; -function deployContract(code) { - return new Action({ deployContract: new DeployContract({ code }) }); -} -exports.deployContract = deployContract; -/** - * Constructs {@link Action} instance representing contract method call. - * - * @param methodName the name of the method to call - * @param args arguments to pass to method. Can be either plain JS object which gets serialized as JSON automatically - * or `Uint8Array` instance which represents bytes passed as is. - * @param gas max amount of gas that method call can use - * @param deposit amount of NEAR (in yoctoNEAR) to send together with the call - */ -function functionCall(methodName, args, gas, deposit) { - const anyArgs = args; - const isUint8Array = anyArgs.byteLength !== undefined && anyArgs.byteLength === anyArgs.length; - const serializedArgs = isUint8Array ? args : Buffer.from(JSON.stringify(args)); - return new Action({ functionCall: new FunctionCall({ methodName, args: serializedArgs, gas, deposit }) }); -} -exports.functionCall = functionCall; -function transfer(deposit) { - return new Action({ transfer: new Transfer({ deposit }) }); -} -exports.transfer = transfer; -function stake(stake, publicKey) { - return new Action({ stake: new Stake({ stake, publicKey }) }); -} -exports.stake = stake; -function addKey(publicKey, accessKey) { - return new Action({ addKey: new AddKey({ publicKey, accessKey }) }); -} -exports.addKey = addKey; -function deleteKey(publicKey) { - return new Action({ deleteKey: new DeleteKey({ publicKey }) }); -} -exports.deleteKey = deleteKey; -function deleteAccount(beneficiaryId) { - return new Action({ deleteAccount: new DeleteAccount({ beneficiaryId }) }); -} -exports.deleteAccount = deleteAccount; -class Signature extends enums_1.Assignable { -} -exports.Signature = Signature; -class Transaction extends enums_1.Assignable { - encode() { - return serialize_1.serialize(exports.SCHEMA, this); - } - static decode(bytes) { - return serialize_1.deserialize(exports.SCHEMA, Transaction, bytes); - } -} -exports.Transaction = Transaction; -class SignedTransaction extends enums_1.Assignable { - encode() { - return serialize_1.serialize(exports.SCHEMA, this); - } - static decode(bytes) { - return serialize_1.deserialize(exports.SCHEMA, SignedTransaction, bytes); - } -} -exports.SignedTransaction = SignedTransaction; -/** - * Contains a list of the valid transaction Actions available with this API - */ -class Action extends enums_1.Enum { -} -exports.Action = Action; -exports.SCHEMA = new Map([ - [Signature, { kind: 'struct', fields: [ - ['keyType', 'u8'], - ['data', [64]] - ] }], - [SignedTransaction, { kind: 'struct', fields: [ - ['transaction', Transaction], - ['signature', Signature] - ] }], - [Transaction, { kind: 'struct', fields: [ - ['signerId', 'string'], - ['publicKey', key_pair_1.PublicKey], - ['nonce', 'u64'], - ['receiverId', 'string'], - ['blockHash', [32]], - ['actions', [Action]] - ] }], - [key_pair_1.PublicKey, { kind: 'struct', fields: [ - ['keyType', 'u8'], - ['data', [32]] - ] }], - [AccessKey, { kind: 'struct', fields: [ - ['nonce', 'u64'], - ['permission', AccessKeyPermission], - ] }], - [AccessKeyPermission, { kind: 'enum', field: 'enum', values: [ - ['functionCall', FunctionCallPermission], - ['fullAccess', FullAccessPermission], - ] }], - [FunctionCallPermission, { kind: 'struct', fields: [ - ['allowance', { kind: 'option', type: 'u128' }], - ['receiverId', 'string'], - ['methodNames', ['string']], - ] }], - [FullAccessPermission, { kind: 'struct', fields: [] }], - [Action, { kind: 'enum', field: 'enum', values: [ - ['createAccount', CreateAccount], - ['deployContract', DeployContract], - ['functionCall', FunctionCall], - ['transfer', Transfer], - ['stake', Stake], - ['addKey', AddKey], - ['deleteKey', DeleteKey], - ['deleteAccount', DeleteAccount], - ] }], - [CreateAccount, { kind: 'struct', fields: [] }], - [DeployContract, { kind: 'struct', fields: [ - ['code', ['u8']] - ] }], - [FunctionCall, { kind: 'struct', fields: [ - ['methodName', 'string'], - ['args', ['u8']], - ['gas', 'u64'], - ['deposit', 'u128'] - ] }], - [Transfer, { kind: 'struct', fields: [ - ['deposit', 'u128'] - ] }], - [Stake, { kind: 'struct', fields: [ - ['stake', 'u128'], - ['publicKey', key_pair_1.PublicKey] - ] }], - [AddKey, { kind: 'struct', fields: [ - ['publicKey', key_pair_1.PublicKey], - ['accessKey', AccessKey] - ] }], - [DeleteKey, { kind: 'struct', fields: [ - ['publicKey', key_pair_1.PublicKey] - ] }], - [DeleteAccount, { kind: 'struct', fields: [ - ['beneficiaryId', 'string'] - ] }], -]); -function createTransaction(signerId, publicKey, receiverId, nonce, actions, blockHash) { - return new Transaction({ signerId, publicKey, nonce, receiverId, actions, blockHash }); -} -exports.createTransaction = createTransaction; -/** - * Signs a given transaction from an account with given keys, applied to the given network - * @param transaction The Transaction object to sign - * @param signer The {Signer} object that assists with signing keys - * @param accountId The human-readable NEAR account name - * @param networkId The targeted network. (ex. default, betanet, etc…) - */ -async function signTransactionObject(transaction, signer, accountId, networkId) { - const message = serialize_1.serialize(exports.SCHEMA, transaction); - const hash = new Uint8Array(js_sha256_1.default.sha256.array(message)); - const signature = await signer.signMessage(message, accountId, networkId); - const signedTx = new SignedTransaction({ - transaction, - signature: new Signature({ keyType: transaction.publicKey.keyType, data: signature.signature }) - }); - return [hash, signedTx]; -} -async function signTransaction(...args) { - if (args[0].constructor === Transaction) { - const [transaction, signer, accountId, networkId] = args; - return signTransactionObject(transaction, signer, accountId, networkId); - } - else { - const [receiverId, nonce, actions, blockHash, signer, accountId, networkId] = args; - const publicKey = await signer.getPublicKey(accountId, networkId); - const transaction = createTransaction(accountId, publicKey, receiverId, nonce, actions, blockHash); - return signTransactionObject(transaction, signer, accountId, networkId); - } -} -exports.signTransaction = signTransaction; diff --git a/package.json b/package.json index 367eb21f7..aeeee0b3d 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "scripts": { "build": "tsc -p ./tsconfig.json", "test": "jest test --runInBand", - "fuzz": "jsfuzz borsh-ts/test/fuzz/borsh-roundtrip.js borsh-ts/test/fuzz/corpus/", "dev": "yarn build -w", "pretest": "yarn build", "lint": "eslint borsh-ts/**/*.ts", @@ -52,7 +51,6 @@ "eslint": "^6.5.1", "jest": "^26.0.1", "js-sha256": "^0.9.0", - "jsfuzz": "^1.0.14", "prettier": "^2.4.1", "typescript": "^3.6.2" },