Skip to content

Commit a8d2775

Browse files
committed
feat(accounts): add basic functions to accounts package
1 parent 711ed23 commit a8d2775

24 files changed

+414
-77
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ jobs:
1212
- run: bun i --no-save
1313
- run: bun run build
1414
- run: bun run test
15-
- run: bunx pkg-pr-new publish './packages/klesia-sdk'
15+
- run: bunx pkg-pr-new publish './packages/klesia-sdk' './packages/accounts'

apps/docs/src/pages/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { GithubIcon } from 'lucide-react'
1919
</div>
2020
</header>
2121
<section>
22-
<iframe src="https://stackblitz.com/edit/minajs?ctl=1&embed=1&file=index.ts&hideExplorer=1&theme=dark&view=editor" className="w-full h-[500px] border-0 rounded-lg overflow-hidden" />
22+
<iframe src="https://stackblitz.com/edit/minajs?embed=1&file=index.ts&hideExplorer=1&theme=dark&view=editor" className="w-full h-[500px] border-0 rounded-lg overflow-hidden" />
2323
</section>
2424
<section className="card dark:bg-neutral bg-primary">
2525
<div className="card-body gap-8">

bun.lockb

1.08 KB
Binary file not shown.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"rimraf": "^6.0.1",
1717
"tsup": "8.2.3",
1818
"turbo": "^2.0.11",
19+
"type-fest": "^4.26.1",
1920
"typescript": "5.5.4"
2021
},
2122
"workspaces": ["packages/*", "apps/*"],

packages/accounts/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "@mina-js/accounts",
3+
"type": "module",
34
"version": "0.0.1",
45
"module": "dist/index.js",
56
"types": "dist/index.d.ts",
@@ -10,15 +11,18 @@
1011
"import": "./dist/index.js"
1112
}
1213
},
14+
"files": ["dist"],
1315
"scripts": {
1416
"build": "tsup",
1517
"test": "bun test",
1618
"cleanup": "rimraf dist .turbo"
1719
},
1820
"dependencies": {
1921
"@mina-js/providers": "workspace:*",
22+
"@noble/ciphers": "^0.6.0",
2023
"@noble/curves": "1.4.2",
2124
"@noble/hashes": "1.4.0",
25+
"@scure/base": "^1.1.8",
2226
"@scure/bip32": "1.4.0",
2327
"@scure/bip39": "1.3.0",
2428
"mina-signer": "3.0.7"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Bun Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`matches the snapshot 1`] = `
4+
{
5+
"createNullifier": [Function: AsyncFunction],
6+
"getHdKey": [Function],
7+
"publicKey": "B62qkYa1o6Mj6uTTjDQCob7FYZspuhkm4RRQhgJg9j4koEBWiSrTQrS",
8+
"signFields": [Function: AsyncFunction],
9+
"signMessage": [Function: AsyncFunction],
10+
"signTransaction": [Function: AsyncFunction],
11+
"source": "hd",
12+
"type": "local",
13+
}
14+
`;
15+
16+
exports[`derives with accountIndex 1`] = `"B62qpmbhZAQHHQHSMwngKy7NuNSEQav7GeTPKRQ9FSdPChAnYiwWyLz"`;
17+
18+
exports[`derives with changeIndex 1`] = `"B62qoxndFokiZ2K4uCNV8673xV3V2qPcmZuQKHBQ1Zm4Narz7keS5bj"`;
19+
20+
exports[`signs a message 1`] = `
21+
{
22+
"data": "hello word",
23+
"publicKey": "B62qkYa1o6Mj6uTTjDQCob7FYZspuhkm4RRQhgJg9j4koEBWiSrTQrS",
24+
"signature": {
25+
"field": "1737565114197582632206802090873583593478816160361909498260553982818075524406",
26+
"scalar": "8097562446343817256257278438860076058640076299120594151149598887065384496675",
27+
},
28+
}
29+
`;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Bun Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`matches the snapshot 1`] = `
4+
{
5+
"createNullifier": [Function: AsyncFunction],
6+
"getHdKey": [Function],
7+
"publicKey": "B62qkYa1o6Mj6uTTjDQCob7FYZspuhkm4RRQhgJg9j4koEBWiSrTQrS",
8+
"signFields": [Function: AsyncFunction],
9+
"signMessage": [Function: AsyncFunction],
10+
"signTransaction": [Function: AsyncFunction],
11+
"source": "hd",
12+
"type": "local",
13+
}
14+
`;
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Bun Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`matches default values 1`] = `
4+
{
5+
"createNullifier": [Function: AsyncFunction],
6+
"publicKey": "B62qmWKtvNQTtUqo1LxfEEDLyWMg59cp6U7c4uDC7aqgaCEijSc3Hx5",
7+
"signFields": [Function: AsyncFunction],
8+
"signMessage": [Function: AsyncFunction],
9+
"signTransaction": [Function: AsyncFunction],
10+
"source": "privateKey",
11+
"type": "local",
12+
}
13+
`;
14+
15+
exports[`signs a message 1`] = `
16+
{
17+
"data": "hello world",
18+
"publicKey": "B62qmWKtvNQTtUqo1LxfEEDLyWMg59cp6U7c4uDC7aqgaCEijSc3Hx5",
19+
"signature": {
20+
"field": "26035766330205137973322965816888613275878847328888669700853142209707796713851",
21+
"scalar": "19081530095096912440933327980723294881571166019208938317545493475572505570273",
22+
},
23+
}
24+
`;
25+
26+
exports[`signs a transaction 1`] = `
27+
{
28+
"data": {
29+
"amount": 3000000000n,
30+
"fee": 100000000n,
31+
"from": "B62qmWKtvNQTtUqo1LxfEEDLyWMg59cp6U7c4uDC7aqgaCEijSc3Hx5",
32+
"memo": "",
33+
"nonce": 1n,
34+
"to": "B62qmWKtvNQTtUqo1LxfEEDLyWMg59cp6U7c4uDC7aqgaCEijSc3Hx5",
35+
"validUntil": 4294967295n,
36+
},
37+
"publicKey": "B62qmWKtvNQTtUqo1LxfEEDLyWMg59cp6U7c4uDC7aqgaCEijSc3Hx5",
38+
"signature": {
39+
"field": "14481941291402553573872495627690275042434233928114864565201875644822981729719",
40+
"scalar": "22662322359617803596615419576835284136875294231266919676620712008667696490687",
41+
},
42+
}
43+
`;
44+
45+
exports[`signs fields 1`] = `
46+
{
47+
"data": [
48+
1n,
49+
2n,
50+
3n,
51+
],
52+
"publicKey": "B62qmWKtvNQTtUqo1LxfEEDLyWMg59cp6U7c4uDC7aqgaCEijSc3Hx5",
53+
"signature": "7mXCUvhLhFvG9ptrdfNceCrpThkCUyg1ct2z8uwY7eQbKz7UNmhv33TbuDjTznaypJtXRiMJyQWDnf27TH1FSXG7uJHTKAd9",
54+
}
55+
`;

packages/accounts/src/generate-mnemonic.spec.ts renamed to packages/accounts/src/accounts/generate-mnemonic.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect, it } from "bun:test";
2-
import { english } from ".";
2+
import { english } from "../";
33
import { generateMnemonic } from "./generate-mnemonic";
44

55
it("generates 12 word mnemonic", () => {

0 commit comments

Comments
 (0)