@ledgerhq/coin-solana 0.20.0 → 0.20.1-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/lib/network/chain/web3.integ.test.d.ts +2 -0
- package/lib/network/chain/web3.integ.test.d.ts.map +1 -0
- package/lib/network/chain/web3.integ.test.js +70 -0
- package/lib/network/chain/web3.integ.test.js.map +1 -0
- package/lib-es/network/chain/web3.integ.test.d.ts +2 -0
- package/lib-es/network/chain/web3.integ.test.d.ts.map +1 -0
- package/lib-es/network/chain/web3.integ.test.js +68 -0
- package/lib-es/network/chain/web3.integ.test.js.map +1 -0
- package/package.json +2 -2
- package/src/network/chain/web3.integ.test.ts +76 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @ledgerhq/coin-solana
|
|
2
2
|
|
|
3
|
+
## 0.20.1-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`cf2bf99`](https://github.com/LedgerHQ/ledger-live/commit/cf2bf99ba44e6eaf20e16cb320c0b22068340601)]:
|
|
8
|
+
- @ledgerhq/coin-framework@4.0.0-next.0
|
|
9
|
+
|
|
3
10
|
## 0.20.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web3.integ.test.d.ts","sourceRoot":"","sources":["../../../src/network/chain/web3.integ.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const superstruct_1 = require("superstruct");
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const constants_1 = require("./program/constants");
|
|
6
|
+
const pubkey_1 = require("./validators/pubkey");
|
|
7
|
+
const web3_1 = require("./web3");
|
|
8
|
+
const api = (0, _1.getChainAPI)({
|
|
9
|
+
endpoint: "https://solana.coin.ledger.com",
|
|
10
|
+
});
|
|
11
|
+
const usdcMintAddress = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; // USDC Mint address
|
|
12
|
+
const usdtMintAddress = "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"; // USDT Mint address
|
|
13
|
+
const account1 = {
|
|
14
|
+
solAccountAddress: "7VHUFJHWu2CuExkJcJrzhQPJ2oygupTWkL2A2For4BmE", // Circle account address
|
|
15
|
+
tokenAccountAddress: "3emsAVdmGKERbHjmGfQ6oZ1e35dkf5iYcS6U4CPKFVaa", // Token account owning the supply for Circle
|
|
16
|
+
ataAddress: "4kokFKCFMxpCpG41yLYkLEqXW8g1WPfCt2NC9KGivY6N", // Computed ATA address, which is not used to own USDC. Thus the account exists, it has a balance too weak.
|
|
17
|
+
};
|
|
18
|
+
const account2 = {
|
|
19
|
+
solAccountAddress: "HYe4vSaEGqQKnDrxWDrk3o5H2gznv7qtij5G6NNG8WHd",
|
|
20
|
+
ataAddress: "HMhsfjwxHcgvfKJatsbhPxhPFKWYPbPUd8FUAGQ79RJ2",
|
|
21
|
+
};
|
|
22
|
+
describe("getMaybeTokenAccount", () => {
|
|
23
|
+
it.each([
|
|
24
|
+
{
|
|
25
|
+
address: account1.tokenAccountAddress,
|
|
26
|
+
mint: usdcMintAddress,
|
|
27
|
+
owner: account1.solAccountAddress,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
address: account2.ataAddress,
|
|
31
|
+
mint: usdtMintAddress,
|
|
32
|
+
owner: account2.solAccountAddress,
|
|
33
|
+
},
|
|
34
|
+
])("returns account info", async ({ address, mint, owner }) => {
|
|
35
|
+
const accountInfo = await (0, web3_1.getMaybeTokenAccount)(address, api);
|
|
36
|
+
expect(accountInfo).toEqual({
|
|
37
|
+
isNative: false,
|
|
38
|
+
mint: (0, superstruct_1.create)(mint, pubkey_1.PublicKeyFromString),
|
|
39
|
+
owner: (0, superstruct_1.create)(owner, pubkey_1.PublicKeyFromString),
|
|
40
|
+
state: "initialized",
|
|
41
|
+
tokenAmount: expect.objectContaining({
|
|
42
|
+
decimals: 6,
|
|
43
|
+
}),
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
it("returns account info", async () => {
|
|
47
|
+
const address = account2.solAccountAddress;
|
|
48
|
+
const accountInfo = await (0, web3_1.getMaybeTokenAccount)(address, api);
|
|
49
|
+
expect(accountInfo).toBeUndefined();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
describe("findTokenAccAddress", () => {
|
|
53
|
+
it.each([
|
|
54
|
+
{
|
|
55
|
+
// address: account1.tokenAccountAddress, // Token Address --> real one onchain
|
|
56
|
+
address: account1.ataAddress, // ATA Address --> doesn't exist onchain
|
|
57
|
+
mint: usdcMintAddress,
|
|
58
|
+
owner: account1.solAccountAddress,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
address: account2.ataAddress,
|
|
62
|
+
mint: usdtMintAddress,
|
|
63
|
+
owner: account2.solAccountAddress,
|
|
64
|
+
},
|
|
65
|
+
])("returns the expected ATA address", async ({ address, mint, owner }) => {
|
|
66
|
+
const ata = await api.findAssocTokenAccAddress(owner, mint, constants_1.PARSED_PROGRAMS.SPL_TOKEN);
|
|
67
|
+
expect(ata).toEqual(address);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=web3.integ.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web3.integ.test.js","sourceRoot":"","sources":["../../../src/network/chain/web3.integ.test.ts"],"names":[],"mappings":";;AAAA,6CAAqC;AACrC,wBAAgC;AAChC,mDAAsD;AACtD,gDAA0D;AAC1D,iCAA8C;AAE9C,MAAM,GAAG,GAAG,IAAA,cAAW,EAAC;IACtB,QAAQ,EAAE,gCAAgC;CAC3C,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,8CAA8C,CAAC,CA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,CAAC,iBAAiB,CAAC;QAE3C,MAAM,WAAW,GAAG,MAAM,IAAA,2BAAoB,EAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAE7D,MAAM,CAAC,WAAW,CAAC,CAAC,aAAa,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,IAAI,CAAC;QACN;YACE,+EAA+E;YAC/E,OAAO,EAAE,QAAQ,CAAC,UAAU,EAAE,wCAAwC;YACtE,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE,QAAQ,CAAC,iBAAiB;SAClC;QACD;YACE,OAAO,EAAE,QAAQ,CAAC,UAAU;YAC5B,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE,QAAQ,CAAC,iBAAiB;SAClC;KACF,CAAC,CAAC,kCAAkC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;QACxE,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,wBAAwB,CAAC,KAAK,EAAE,IAAI,EAAE,2BAAe,CAAC,SAAS,CAAC,CAAC;QAEvF,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web3.integ.test.d.ts","sourceRoot":"","sources":["../../../src/network/chain/web3.integ.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { create } from "superstruct";
|
|
2
|
+
import { getChainAPI } from ".";
|
|
3
|
+
import { PARSED_PROGRAMS } from "./program/constants";
|
|
4
|
+
import { PublicKeyFromString } from "./validators/pubkey";
|
|
5
|
+
import { getMaybeTokenAccount } from "./web3";
|
|
6
|
+
const api = getChainAPI({
|
|
7
|
+
endpoint: "https://solana.coin.ledger.com",
|
|
8
|
+
});
|
|
9
|
+
const usdcMintAddress = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; // USDC Mint address
|
|
10
|
+
const usdtMintAddress = "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"; // USDT Mint address
|
|
11
|
+
const account1 = {
|
|
12
|
+
solAccountAddress: "7VHUFJHWu2CuExkJcJrzhQPJ2oygupTWkL2A2For4BmE", // Circle account address
|
|
13
|
+
tokenAccountAddress: "3emsAVdmGKERbHjmGfQ6oZ1e35dkf5iYcS6U4CPKFVaa", // Token account owning the supply for Circle
|
|
14
|
+
ataAddress: "4kokFKCFMxpCpG41yLYkLEqXW8g1WPfCt2NC9KGivY6N", // Computed ATA address, which is not used to own USDC. Thus the account exists, it has a balance too weak.
|
|
15
|
+
};
|
|
16
|
+
const account2 = {
|
|
17
|
+
solAccountAddress: "HYe4vSaEGqQKnDrxWDrk3o5H2gznv7qtij5G6NNG8WHd",
|
|
18
|
+
ataAddress: "HMhsfjwxHcgvfKJatsbhPxhPFKWYPbPUd8FUAGQ79RJ2",
|
|
19
|
+
};
|
|
20
|
+
describe("getMaybeTokenAccount", () => {
|
|
21
|
+
it.each([
|
|
22
|
+
{
|
|
23
|
+
address: account1.tokenAccountAddress,
|
|
24
|
+
mint: usdcMintAddress,
|
|
25
|
+
owner: account1.solAccountAddress,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
address: account2.ataAddress,
|
|
29
|
+
mint: usdtMintAddress,
|
|
30
|
+
owner: account2.solAccountAddress,
|
|
31
|
+
},
|
|
32
|
+
])("returns account info", async ({ address, mint, owner }) => {
|
|
33
|
+
const accountInfo = await getMaybeTokenAccount(address, api);
|
|
34
|
+
expect(accountInfo).toEqual({
|
|
35
|
+
isNative: false,
|
|
36
|
+
mint: create(mint, PublicKeyFromString),
|
|
37
|
+
owner: create(owner, PublicKeyFromString),
|
|
38
|
+
state: "initialized",
|
|
39
|
+
tokenAmount: expect.objectContaining({
|
|
40
|
+
decimals: 6,
|
|
41
|
+
}),
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
it("returns account info", async () => {
|
|
45
|
+
const address = account2.solAccountAddress;
|
|
46
|
+
const accountInfo = await getMaybeTokenAccount(address, api);
|
|
47
|
+
expect(accountInfo).toBeUndefined();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
describe("findTokenAccAddress", () => {
|
|
51
|
+
it.each([
|
|
52
|
+
{
|
|
53
|
+
// address: account1.tokenAccountAddress, // Token Address --> real one onchain
|
|
54
|
+
address: account1.ataAddress, // ATA Address --> doesn't exist onchain
|
|
55
|
+
mint: usdcMintAddress,
|
|
56
|
+
owner: account1.solAccountAddress,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
address: account2.ataAddress,
|
|
60
|
+
mint: usdtMintAddress,
|
|
61
|
+
owner: account2.solAccountAddress,
|
|
62
|
+
},
|
|
63
|
+
])("returns the expected ATA address", async ({ address, mint, owner }) => {
|
|
64
|
+
const ata = await api.findAssocTokenAccAddress(owner, mint, PARSED_PROGRAMS.SPL_TOKEN);
|
|
65
|
+
expect(ata).toEqual(address);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=web3.integ.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web3.integ.test.js","sourceRoot":"","sources":["../../../src/network/chain/web3.integ.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAE9C,MAAM,GAAG,GAAG,WAAW,CAAC;IACtB,QAAQ,E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EAAE,KAAK,IAAI,EAAE;QACpC,MAAM,OAAO,GAAG,QAAQ,CAAC,iBAAiB,CAAC;QAE3C,MAAM,WAAW,GAAG,MAAM,oBAAoB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAE7D,MAAM,CAAC,WAAW,CAAC,CAAC,aAAa,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,IAAI,CAAC;QACN;YACE,+EAA+E;YAC/E,OAAO,EAAE,QAAQ,CAAC,UAAU,EAAE,wCAAwC;YACtE,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE,QAAQ,CAAC,iBAAiB;SAClC;QACD;YACE,OAAO,EAAE,QAAQ,CAAC,UAAU;YAC5B,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE,QAAQ,CAAC,iBAAiB;SAClC;KACF,CAAC,CAAC,kCAAkC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;QACxE,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,wBAAwB,CAAC,KAAK,EAAE,IAAI,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;QAEvF,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-solana",
|
|
3
|
-
"version": "0.20.0",
|
|
3
|
+
"version": "0.20.1-next.0",
|
|
4
4
|
"description": "Ledger Solana Coin integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"object-hash": "^2.2.0",
|
|
56
56
|
"rxjs": "^7.8.1",
|
|
57
57
|
"superstruct": "0.16.7",
|
|
58
|
-
"@ledgerhq/coin-framework": "^
|
|
58
|
+
"@ledgerhq/coin-framework": "^4.0.0-next.0",
|
|
59
59
|
"@ledgerhq/cryptoassets": "^13.15.0",
|
|
60
60
|
"@ledgerhq/devices": "8.4.4",
|
|
61
61
|
"@ledgerhq/errors": "^6.19.1",
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { create } from "superstruct";
|
|
2
|
+
import { getChainAPI } from ".";
|
|
3
|
+
import { PARSED_PROGRAMS } from "./program/constants";
|
|
4
|
+
import { PublicKeyFromString } from "./validators/pubkey";
|
|
5
|
+
import { getMaybeTokenAccount } from "./web3";
|
|
6
|
+
|
|
7
|
+
const api = getChainAPI({
|
|
8
|
+
endpoint: "https://solana.coin.ledger.com",
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const usdcMintAddress = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; // USDC Mint address
|
|
12
|
+
const usdtMintAddress = "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"; // USDT Mint address
|
|
13
|
+
const account1 = {
|
|
14
|
+
solAccountAddress: "7VHUFJHWu2CuExkJcJrzhQPJ2oygupTWkL2A2For4BmE", // Circle account address
|
|
15
|
+
tokenAccountAddress: "3emsAVdmGKERbHjmGfQ6oZ1e35dkf5iYcS6U4CPKFVaa", // Token account owning the supply for Circle
|
|
16
|
+
ataAddress: "4kokFKCFMxpCpG41yLYkLEqXW8g1WPfCt2NC9KGivY6N", // Computed ATA address, which is not used to own USDC. Thus the account exists, it has a balance too weak.
|
|
17
|
+
};
|
|
18
|
+
const account2 = {
|
|
19
|
+
solAccountAddress: "HYe4vSaEGqQKnDrxWDrk3o5H2gznv7qtij5G6NNG8WHd",
|
|
20
|
+
ataAddress: "HMhsfjwxHcgvfKJatsbhPxhPFKWYPbPUd8FUAGQ79RJ2",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
describe("getMaybeTokenAccount", () => {
|
|
24
|
+
it.each([
|
|
25
|
+
{
|
|
26
|
+
address: account1.tokenAccountAddress,
|
|
27
|
+
mint: usdcMintAddress,
|
|
28
|
+
owner: account1.solAccountAddress,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
address: account2.ataAddress,
|
|
32
|
+
mint: usdtMintAddress,
|
|
33
|
+
owner: account2.solAccountAddress,
|
|
34
|
+
},
|
|
35
|
+
])("returns account info", async ({ address, mint, owner }) => {
|
|
36
|
+
const accountInfo = await getMaybeTokenAccount(address, api);
|
|
37
|
+
|
|
38
|
+
expect(accountInfo).toEqual({
|
|
39
|
+
isNative: false,
|
|
40
|
+
mint: create(mint, PublicKeyFromString),
|
|
41
|
+
owner: create(owner, PublicKeyFromString),
|
|
42
|
+
state: "initialized",
|
|
43
|
+
tokenAmount: expect.objectContaining({
|
|
44
|
+
decimals: 6,
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("returns account info", async () => {
|
|
50
|
+
const address = account2.solAccountAddress;
|
|
51
|
+
|
|
52
|
+
const accountInfo = await getMaybeTokenAccount(address, api);
|
|
53
|
+
|
|
54
|
+
expect(accountInfo).toBeUndefined();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe("findTokenAccAddress", () => {
|
|
59
|
+
it.each([
|
|
60
|
+
{
|
|
61
|
+
// address: account1.tokenAccountAddress, // Token Address --> real one onchain
|
|
62
|
+
address: account1.ataAddress, // ATA Address --> doesn't exist onchain
|
|
63
|
+
mint: usdcMintAddress,
|
|
64
|
+
owner: account1.solAccountAddress,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
address: account2.ataAddress,
|
|
68
|
+
mint: usdtMintAddress,
|
|
69
|
+
owner: account2.solAccountAddress,
|
|
70
|
+
},
|
|
71
|
+
])("returns the expected ATA address", async ({ address, mint, owner }) => {
|
|
72
|
+
const ata = await api.findAssocTokenAccAddress(owner, mint, PARSED_PROGRAMS.SPL_TOKEN);
|
|
73
|
+
|
|
74
|
+
expect(ata).toEqual(address);
|
|
75
|
+
});
|
|
76
|
+
});
|