@ledgerhq/coin-framework 5.3.0-next.1 → 5.3.0-nightly.1
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +8 -14
- package/lib/api/types.d.ts +67 -10
- package/lib/api/types.d.ts.map +1 -1
- package/lib/config.d.ts +3 -0
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js.map +1 -1
- package/lib-es/api/types.d.ts +67 -10
- package/lib-es/api/types.d.ts.map +1 -1
- package/lib-es/config.d.ts +3 -0
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js.map +1 -1
- package/package.json +5 -5
- package/src/api/types.ts +100 -23
- package/src/config.ts +4 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @ledgerhq/coin-framework@5.
|
|
2
|
+
> @ledgerhq/coin-framework@5.2.1-nightly.0 build /home/runner/work/ledger-live/ledger-live/libs/coin-framework
|
|
3
3
|
> tsc && tsc -m esnext --moduleResolution bundler --outDir lib-es
|
|
4
4
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,28 +1,22 @@
|
|
|
1
1
|
# @ledgerhq/coin-framework
|
|
2
2
|
|
|
3
|
-
## 5.3.0-
|
|
3
|
+
## 5.3.0-nightly.1
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
|
-
- [#
|
|
7
|
+
- [#10425](https://github.com/LedgerHQ/ledger-live/pull/10425) [`4d9aaf5`](https://github.com/LedgerHQ/ledger-live/commit/4d9aaf583060a22cd1343b23d9b5c1ee3c02abb4) Thanks [@qperrot](https://github.com/qperrot)! - Feature: handle black listed address on swap
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Minor Changes
|
|
12
|
-
|
|
13
|
-
- [#10422](https://github.com/LedgerHQ/ledger-live/pull/10422) [`18bc0d4`](https://github.com/LedgerHQ/ledger-live/commit/18bc0d4a27696491400df6ce26b915a88b56792f) Thanks [@Moustafa-Koterba](https://github.com/Moustafa-Koterba)! - Logic implementation for sanctioned addresses
|
|
9
|
+
### Patch Changes
|
|
14
10
|
|
|
15
|
-
-
|
|
11
|
+
- Updated dependencies [[`e9739d1`](https://github.com/LedgerHQ/ledger-live/commit/e9739d19946376dd7a8a5f10471594f267f3a95f)]:
|
|
12
|
+
- @ledgerhq/types-live@6.73.0-nightly.1
|
|
16
13
|
|
|
17
|
-
|
|
14
|
+
## 5.2.1-nightly.0
|
|
18
15
|
|
|
19
16
|
### Patch Changes
|
|
20
17
|
|
|
21
|
-
- Updated dependencies [[`
|
|
22
|
-
- @ledgerhq/live
|
|
23
|
-
- @ledgerhq/types-live@6.73.0-next.0
|
|
24
|
-
- @ledgerhq/cryptoassets@13.18.1-next.0
|
|
25
|
-
- @ledgerhq/live-network@2.0.10-next.0
|
|
18
|
+
- Updated dependencies [[`9ceee03`](https://github.com/LedgerHQ/ledger-live/commit/9ceee03c33c41bb035fe64f9303acd36872536b6)]:
|
|
19
|
+
- @ledgerhq/types-live@6.73.0-nightly.0
|
|
26
20
|
|
|
27
21
|
## 5.2.0
|
|
28
22
|
|
package/lib/api/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Unit } from "@ledgerhq/types-cryptoassets";
|
|
1
2
|
export type BlockInfo = {
|
|
2
3
|
height: number;
|
|
3
4
|
hash?: string;
|
|
@@ -9,13 +10,23 @@ export type Asset<TokenInfo extends TokenInfoCommon = never> = {
|
|
|
9
10
|
} | (TokenInfo extends never ? TokenInfo : {
|
|
10
11
|
type: "token";
|
|
11
12
|
} & TokenInfo);
|
|
12
|
-
export type Operation<AssetInfo extends Asset<TokenInfoCommon
|
|
13
|
+
export type Operation<AssetInfo extends Asset<TokenInfoCommon> = Asset<TokenInfoCommon>, MemoType extends Memo = MemoNotSupported> = {
|
|
13
14
|
id: string;
|
|
14
15
|
type: string;
|
|
15
16
|
senders: string[];
|
|
16
17
|
recipients: string[];
|
|
17
18
|
value: bigint;
|
|
18
19
|
asset: AssetInfo;
|
|
20
|
+
/**
|
|
21
|
+
* Optional memo associated with the operation.
|
|
22
|
+
* Use a `Memo` interface like `StringMemo<"text">`, `MapMemo<Kind, Value>`, or `MyMemo`.
|
|
23
|
+
* Defaults to `MemoNotSupported`.
|
|
24
|
+
*/
|
|
25
|
+
memo?: MemoType;
|
|
26
|
+
/**
|
|
27
|
+
* Arbitrary per-blockchain extra fields.
|
|
28
|
+
* This can include things like status, error messages, swap info, etc.
|
|
29
|
+
*/
|
|
19
30
|
details?: Record<string, unknown>;
|
|
20
31
|
tx: {
|
|
21
32
|
hash: string;
|
|
@@ -30,32 +41,78 @@ export type Transaction = {
|
|
|
30
41
|
amount: bigint;
|
|
31
42
|
fee: bigint;
|
|
32
43
|
} & Record<string, unknown>;
|
|
44
|
+
export type Account = {
|
|
45
|
+
currencyName: string;
|
|
46
|
+
address: string;
|
|
47
|
+
balance: bigint;
|
|
48
|
+
currencyUnit: Unit;
|
|
49
|
+
};
|
|
33
50
|
export type Balance<AssetInfo extends Asset<TokenInfoCommon>> = {
|
|
34
51
|
value: bigint;
|
|
52
|
+
locked?: bigint;
|
|
35
53
|
asset: AssetInfo;
|
|
36
54
|
};
|
|
37
|
-
export
|
|
55
|
+
export interface Memo {
|
|
56
|
+
type: string;
|
|
57
|
+
}
|
|
58
|
+
export interface MemoNotSupported extends Memo {
|
|
59
|
+
type: "none";
|
|
60
|
+
}
|
|
61
|
+
export interface StringMemo<Kind extends string = "text"> extends Memo {
|
|
62
|
+
type: "string";
|
|
63
|
+
kind: Kind;
|
|
64
|
+
value: string;
|
|
65
|
+
}
|
|
66
|
+
export interface MapMemo<Kind extends string, Value> extends Memo {
|
|
67
|
+
type: "map";
|
|
68
|
+
memos: Map<Kind, Value>;
|
|
69
|
+
}
|
|
70
|
+
export interface TypedMapMemo<KindToValueMap extends Record<string, unknown>> extends Memo {
|
|
71
|
+
type: "map";
|
|
72
|
+
memos: Map<keyof KindToValueMap, KindToValueMap[keyof KindToValueMap]>;
|
|
73
|
+
}
|
|
74
|
+
type MaybeMemo<MemoType extends Memo> = MemoType extends MemoNotSupported ? {} : {
|
|
75
|
+
memo: MemoType;
|
|
76
|
+
};
|
|
77
|
+
export type TransactionIntent<AssetInfo extends Asset<TokenInfoCommon>, MemoType extends Memo = MemoNotSupported> = {
|
|
38
78
|
type: string;
|
|
39
|
-
sender:
|
|
79
|
+
sender: string;
|
|
80
|
+
senderPublicKey?: string;
|
|
81
|
+
expiration?: number;
|
|
40
82
|
recipient: string;
|
|
41
83
|
amount: bigint;
|
|
42
84
|
asset: AssetInfo;
|
|
43
|
-
} &
|
|
44
|
-
export type
|
|
85
|
+
} & MaybeMemo<MemoType>;
|
|
86
|
+
export type TransactionValidation = {
|
|
87
|
+
errors: Record<string, Error>;
|
|
88
|
+
warnings: Record<string, Error>;
|
|
89
|
+
estimatedFees: bigint;
|
|
90
|
+
amount: bigint;
|
|
91
|
+
totalSpent: bigint;
|
|
92
|
+
};
|
|
93
|
+
export type FeeEstimation = {
|
|
45
94
|
value: bigint;
|
|
46
|
-
parameters?:
|
|
95
|
+
parameters?: {
|
|
96
|
+
storageLimit: bigint;
|
|
97
|
+
gasLimit: bigint;
|
|
98
|
+
gasPrice?: bigint;
|
|
99
|
+
};
|
|
47
100
|
};
|
|
48
101
|
export type Pagination = {
|
|
49
102
|
minHeight: number;
|
|
50
103
|
};
|
|
51
|
-
export type
|
|
104
|
+
export type AlpacaApi<AssetInfo extends Asset<TokenInfoCommon>, MemoType extends Memo = MemoNotSupported> = {
|
|
52
105
|
broadcast: (tx: string) => Promise<string>;
|
|
53
|
-
combine: (tx: string, signature: string, pubkey?: string) => string
|
|
54
|
-
estimateFees: (transactionIntent: TransactionIntent<AssetInfo,
|
|
55
|
-
craftTransaction: (transactionIntent: TransactionIntent<AssetInfo,
|
|
106
|
+
combine: (tx: string, signature: string, pubkey?: string) => string | Promise<string>;
|
|
107
|
+
estimateFees: (transactionIntent: TransactionIntent<AssetInfo, MemoType>) => Promise<FeeEstimation>;
|
|
108
|
+
craftTransaction: (transactionIntent: TransactionIntent<AssetInfo, MemoType>, customFees?: bigint) => Promise<string>;
|
|
56
109
|
getBalance: (address: string) => Promise<Balance<AssetInfo>[]>;
|
|
57
110
|
lastBlock: () => Promise<BlockInfo>;
|
|
58
111
|
listOperations: (address: string, pagination: Pagination) => Promise<[Operation<AssetInfo>[], string]>;
|
|
59
112
|
};
|
|
113
|
+
export type BridgeApi = {
|
|
114
|
+
validateIntent: (account: Account, transaction: Transaction) => Promise<TransactionValidation>;
|
|
115
|
+
};
|
|
116
|
+
export type Api<AssetInfo extends Asset<TokenInfoCommon>, MemoType extends Memo = MemoNotSupported> = AlpacaApi<AssetInfo, MemoType> & BridgeApi;
|
|
60
117
|
export {};
|
|
61
118
|
//# sourceMappingURL=types.d.ts.map
|
package/lib/api/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IAId,IAAI,CAAC,EAAE,IAAI,CAAC;CACb,CAAC;AAEF,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE/C,MAAM,MAAM,KAAK,CAAC,SAAS,SAAS,eAAe,GAAG,KAAK,IACvD;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB,CAAC,SAAS,SAAS,KAAK,GAAG,SAAS,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAAC,CAAC;AAE1E,MAAM,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA,OA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C,MAAM,CAAC,CAAC;IACtF,YAAY,EAAE,CACZ,iBAAiB,EAAE,iBAAiB,CAAC,SAAS,EAAE,QAAQ,CAAC,KACtD,OAAO,CAAC,aAAa,CAAC,CAAC;IAC5B,gBAAgB,EAAE,CAChB,iBAAiB,EAAE,iBAAiB,CAAC,SAAS,EAAE,QAAQ,CAAC,EACzD,UAAU,CAAC,EAAE,MAAM,KAChB,OAAO,CAAC,MAAM,CAAC,CAAC;IACrB,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC/D,SAAS,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC,cAAc,EAAE,CACd,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,UAAU,KACnB,OAAO,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,cAAc,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAChG,CAAC;AAEF,MAAM,MAAM,GAAG,CACb,SAAS,SAAS,KAAK,CAAC,eAAe,CAAC,EACxC,QAAQ,SAAS,IAAI,GAAG,gBAAgB,IACtC,SAAS,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,SAAS,CAAC"}
|
package/lib/config.d.ts
CHANGED
|
@@ -25,6 +25,9 @@ export type CurrencyConfig = {
|
|
|
25
25
|
[key: string]: unknown;
|
|
26
26
|
};
|
|
27
27
|
export type CoinConfig<T extends CurrencyConfig> = (currency?: CryptoCurrency) => T;
|
|
28
|
+
export type SharedConfig = {
|
|
29
|
+
checkBlacklistAddress?: boolean;
|
|
30
|
+
};
|
|
28
31
|
declare function buildCoinConfig<T extends CurrencyConfig>(): {
|
|
29
32
|
setCoinConfig: (config: CoinConfig<T>) => void;
|
|
30
33
|
getCoinConfig: (currency?: CryptoCurrency) => T;
|
package/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGhF,KAAK,YAAY,GACb;IACE,IAAI,EAAE,QAAQ,CAAC;CAChB,GACD;IACE,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,gBAAgB,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EACH,SAAS,GACT,MAAM,GACN,eAAe,GACf,kBAAkB,GAClB,MAAM,GACN,SAAS,GACT,gBAAgB,GAChB,kBAAkB,GAClB,SAAS,GACT,0BAA0B,CAAC;CAChC,GACD;IACE,IAAI,EAAE,oBAAoB,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;CACzB,GACD;IACE,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEN,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,YAAY,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,cAAc,IAAI,CAAC,QAAQ,CAAC,EAAE,cAAc,KAAK,CAAC,CAAC;AAEpF,iBAAS,eAAe,CAAC,CAAC,SAAS,cAAc;4BAGhB,WAAW,CAAC,CAAC,KAAG,IAAI;+BAIjB,cAAc,KAAG,CAAC;EAYrD;AAED,eAAe,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGhF,KAAK,YAAY,GACb;IACE,IAAI,EAAE,QAAQ,CAAC;CAChB,GACD;IACE,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,gBAAgB,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EACH,SAAS,GACT,MAAM,GACN,eAAe,GACf,kBAAkB,GAClB,MAAM,GACN,SAAS,GACT,gBAAgB,GAChB,kBAAkB,GAClB,SAAS,GACT,0BAA0B,CAAC;CAChC,GACD;IACE,IAAI,EAAE,oBAAoB,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;CACzB,GACD;IACE,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEN,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,YAAY,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,cAAc,IAAI,CAAC,QAAQ,CAAC,EAAE,cAAc,KAAK,CAAC,CAAC;AAEpF,MAAM,MAAM,YAAY,GAAG;IACzB,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,iBAAS,eAAe,CAAC,CAAC,SAAS,cAAc;4BAGhB,WAAW,CAAC,CAAC,KAAG,IAAI;+BAIjB,cAAc,KAAG,CAAC;EAYrD;AAED,eAAe,eAAe,CAAC"}
|
package/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;AACA,qCAA6C;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;AACA,qCAA6C;AAmD7C,SAAS,eAAe;IACtB,IAAI,UAAqC,CAAC;IAE1C,MAAM,aAAa,GAAG,CAAC,MAAqB,EAAQ,EAAE;QACpD,UAAU,GAAG,MAAM,CAAC;IACtB,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,CAAC,QAAyB,EAAK,EAAE;QACrD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,0BAAiB,EAAE,CAAC;QAChC,CAAC;QAED,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC,CAAC;IAEF,OAAO;QACL,aAAa;QACb,aAAa;KACd,CAAC;AACJ,CAAC;AAED,kBAAe,eAAe,CAAC"}
|
package/lib-es/api/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Unit } from "@ledgerhq/types-cryptoassets";
|
|
1
2
|
export type BlockInfo = {
|
|
2
3
|
height: number;
|
|
3
4
|
hash?: string;
|
|
@@ -9,13 +10,23 @@ export type Asset<TokenInfo extends TokenInfoCommon = never> = {
|
|
|
9
10
|
} | (TokenInfo extends never ? TokenInfo : {
|
|
10
11
|
type: "token";
|
|
11
12
|
} & TokenInfo);
|
|
12
|
-
export type Operation<AssetInfo extends Asset<TokenInfoCommon
|
|
13
|
+
export type Operation<AssetInfo extends Asset<TokenInfoCommon> = Asset<TokenInfoCommon>, MemoType extends Memo = MemoNotSupported> = {
|
|
13
14
|
id: string;
|
|
14
15
|
type: string;
|
|
15
16
|
senders: string[];
|
|
16
17
|
recipients: string[];
|
|
17
18
|
value: bigint;
|
|
18
19
|
asset: AssetInfo;
|
|
20
|
+
/**
|
|
21
|
+
* Optional memo associated with the operation.
|
|
22
|
+
* Use a `Memo` interface like `StringMemo<"text">`, `MapMemo<Kind, Value>`, or `MyMemo`.
|
|
23
|
+
* Defaults to `MemoNotSupported`.
|
|
24
|
+
*/
|
|
25
|
+
memo?: MemoType;
|
|
26
|
+
/**
|
|
27
|
+
* Arbitrary per-blockchain extra fields.
|
|
28
|
+
* This can include things like status, error messages, swap info, etc.
|
|
29
|
+
*/
|
|
19
30
|
details?: Record<string, unknown>;
|
|
20
31
|
tx: {
|
|
21
32
|
hash: string;
|
|
@@ -30,32 +41,78 @@ export type Transaction = {
|
|
|
30
41
|
amount: bigint;
|
|
31
42
|
fee: bigint;
|
|
32
43
|
} & Record<string, unknown>;
|
|
44
|
+
export type Account = {
|
|
45
|
+
currencyName: string;
|
|
46
|
+
address: string;
|
|
47
|
+
balance: bigint;
|
|
48
|
+
currencyUnit: Unit;
|
|
49
|
+
};
|
|
33
50
|
export type Balance<AssetInfo extends Asset<TokenInfoCommon>> = {
|
|
34
51
|
value: bigint;
|
|
52
|
+
locked?: bigint;
|
|
35
53
|
asset: AssetInfo;
|
|
36
54
|
};
|
|
37
|
-
export
|
|
55
|
+
export interface Memo {
|
|
56
|
+
type: string;
|
|
57
|
+
}
|
|
58
|
+
export interface MemoNotSupported extends Memo {
|
|
59
|
+
type: "none";
|
|
60
|
+
}
|
|
61
|
+
export interface StringMemo<Kind extends string = "text"> extends Memo {
|
|
62
|
+
type: "string";
|
|
63
|
+
kind: Kind;
|
|
64
|
+
value: string;
|
|
65
|
+
}
|
|
66
|
+
export interface MapMemo<Kind extends string, Value> extends Memo {
|
|
67
|
+
type: "map";
|
|
68
|
+
memos: Map<Kind, Value>;
|
|
69
|
+
}
|
|
70
|
+
export interface TypedMapMemo<KindToValueMap extends Record<string, unknown>> extends Memo {
|
|
71
|
+
type: "map";
|
|
72
|
+
memos: Map<keyof KindToValueMap, KindToValueMap[keyof KindToValueMap]>;
|
|
73
|
+
}
|
|
74
|
+
type MaybeMemo<MemoType extends Memo> = MemoType extends MemoNotSupported ? {} : {
|
|
75
|
+
memo: MemoType;
|
|
76
|
+
};
|
|
77
|
+
export type TransactionIntent<AssetInfo extends Asset<TokenInfoCommon>, MemoType extends Memo = MemoNotSupported> = {
|
|
38
78
|
type: string;
|
|
39
|
-
sender:
|
|
79
|
+
sender: string;
|
|
80
|
+
senderPublicKey?: string;
|
|
81
|
+
expiration?: number;
|
|
40
82
|
recipient: string;
|
|
41
83
|
amount: bigint;
|
|
42
84
|
asset: AssetInfo;
|
|
43
|
-
} &
|
|
44
|
-
export type
|
|
85
|
+
} & MaybeMemo<MemoType>;
|
|
86
|
+
export type TransactionValidation = {
|
|
87
|
+
errors: Record<string, Error>;
|
|
88
|
+
warnings: Record<string, Error>;
|
|
89
|
+
estimatedFees: bigint;
|
|
90
|
+
amount: bigint;
|
|
91
|
+
totalSpent: bigint;
|
|
92
|
+
};
|
|
93
|
+
export type FeeEstimation = {
|
|
45
94
|
value: bigint;
|
|
46
|
-
parameters?:
|
|
95
|
+
parameters?: {
|
|
96
|
+
storageLimit: bigint;
|
|
97
|
+
gasLimit: bigint;
|
|
98
|
+
gasPrice?: bigint;
|
|
99
|
+
};
|
|
47
100
|
};
|
|
48
101
|
export type Pagination = {
|
|
49
102
|
minHeight: number;
|
|
50
103
|
};
|
|
51
|
-
export type
|
|
104
|
+
export type AlpacaApi<AssetInfo extends Asset<TokenInfoCommon>, MemoType extends Memo = MemoNotSupported> = {
|
|
52
105
|
broadcast: (tx: string) => Promise<string>;
|
|
53
|
-
combine: (tx: string, signature: string, pubkey?: string) => string
|
|
54
|
-
estimateFees: (transactionIntent: TransactionIntent<AssetInfo,
|
|
55
|
-
craftTransaction: (transactionIntent: TransactionIntent<AssetInfo,
|
|
106
|
+
combine: (tx: string, signature: string, pubkey?: string) => string | Promise<string>;
|
|
107
|
+
estimateFees: (transactionIntent: TransactionIntent<AssetInfo, MemoType>) => Promise<FeeEstimation>;
|
|
108
|
+
craftTransaction: (transactionIntent: TransactionIntent<AssetInfo, MemoType>, customFees?: bigint) => Promise<string>;
|
|
56
109
|
getBalance: (address: string) => Promise<Balance<AssetInfo>[]>;
|
|
57
110
|
lastBlock: () => Promise<BlockInfo>;
|
|
58
111
|
listOperations: (address: string, pagination: Pagination) => Promise<[Operation<AssetInfo>[], string]>;
|
|
59
112
|
};
|
|
113
|
+
export type BridgeApi = {
|
|
114
|
+
validateIntent: (account: Account, transaction: Transaction) => Promise<TransactionValidation>;
|
|
115
|
+
};
|
|
116
|
+
export type Api<AssetInfo extends Asset<TokenInfoCommon>, MemoType extends Memo = MemoNotSupported> = AlpacaApi<AssetInfo, MemoType> & BridgeApi;
|
|
60
117
|
export {};
|
|
61
118
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IAId,IAAI,CAAC,EAAE,IAAI,CAAC;CACb,CAAC;AAEF,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE/C,MAAM,MAAM,KAAK,CAAC,SAAS,SAAS,eAAe,GAAG,KAAK,IACvD;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB,CAAC,SAAS,SAAS,KAAK,GAAG,SAAS,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAAC,CAAC;AAE1E,MAAM,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAEpD,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IAId,IAAI,CAAC,EAAE,IAA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AAiB,EAAE,iBAAiB,CAAC,SAAS,EAAE,QAAQ,CAAC,EACzD,UAAU,CAAC,EAAE,MAAM,KAChB,OAAO,CAAC,MAAM,CAAC,CAAC;IACrB,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC/D,SAAS,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC,cAAc,EAAE,CACd,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,UAAU,KACnB,OAAO,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,cAAc,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAChG,CAAC;AAEF,MAAM,MAAM,GAAG,CACb,SAAS,SAAS,KAAK,CAAC,eAAe,CAAC,EACxC,QAAQ,SAAS,IAAI,GAAG,gBAAgB,IACtC,SAAS,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,SAAS,CAAC"}
|
package/lib-es/config.d.ts
CHANGED
|
@@ -25,6 +25,9 @@ export type CurrencyConfig = {
|
|
|
25
25
|
[key: string]: unknown;
|
|
26
26
|
};
|
|
27
27
|
export type CoinConfig<T extends CurrencyConfig> = (currency?: CryptoCurrency) => T;
|
|
28
|
+
export type SharedConfig = {
|
|
29
|
+
checkBlacklistAddress?: boolean;
|
|
30
|
+
};
|
|
28
31
|
declare function buildCoinConfig<T extends CurrencyConfig>(): {
|
|
29
32
|
setCoinConfig: (config: CoinConfig<T>) => void;
|
|
30
33
|
getCoinConfig: (currency?: CryptoCurrency) => T;
|
package/lib-es/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[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ACE,IAAI,EAAE,QAAQ,CAAC;CAChB,GACD;IACE,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,gBAAgB,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EACH,SAAS,GACT,MAAM,GACN,eAAe,GACf,kBAAkB,GAClB,MAAM,GACN,SAAS,GACT,gBAAgB,GAChB,kBAAkB,GAClB,SAAS,GACT,0BAA0B,CAAC;CAChC,GACD;IACE,IAAI,EAAE,oBAAoB,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;CACzB,GACD;IACE,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEN,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,YAAY,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,cAAc,IAAI,CAAC,QAAQ,CAAC,EAAE,cAAc,KAAK,CAAC,CAAC;AAEpF,MAAM,MAAM,YAAY,GAAG;IACzB,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,iBAAS,eAAe,CAAC,CAAC,SAAS,cAAc;4BAGhB,WAAW,CAAC,CAAC,KAAG,IAAI;+BAIjB,cAAc,KAAG,CAAC;EAYrD;AAED,eAAe,eAAe,CAAC"}
|
package/lib-es/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAmD7C,SAAS,eAAe;IACtB,IAAI,UAAqC,CAAC;IAE1C,MAAM,aAAa,GAAG,CAAC,MAAqB,EAAQ,EAAE;QACpD,UAAU,GAAG,MAAM,CAAC;IACtB,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,CAAC,QAAyB,EAAK,EAAE;QACrD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,iBAAiB,EAAE,CAAC;QAChC,CAAC;QAED,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC,CAAC;IAEF,OAAO;QACL,aAAa;QACb,aAAa;KACd,CAAC;AACJ,CAAC;AAED,eAAe,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-framework",
|
|
3
|
-
"version": "5.3.0-
|
|
3
|
+
"version": "5.3.0-nightly.1",
|
|
4
4
|
"description": "Ledger framework for Coin integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -91,14 +91,14 @@
|
|
|
91
91
|
"lodash": "^4.17.21",
|
|
92
92
|
"prando": "^6.0.1",
|
|
93
93
|
"rxjs": "^7.8.1",
|
|
94
|
-
"@ledgerhq/cryptoassets": "^13.18.1-
|
|
94
|
+
"@ledgerhq/cryptoassets": "^13.18.1-nightly.0",
|
|
95
95
|
"@ledgerhq/devices": "8.4.6",
|
|
96
96
|
"@ledgerhq/errors": "^6.21.0",
|
|
97
|
-
"@ledgerhq/live-env": "^2.
|
|
98
|
-
"@ledgerhq/live-network": "^2.0.
|
|
97
|
+
"@ledgerhq/live-env": "^2.9.1-nightly.0",
|
|
98
|
+
"@ledgerhq/live-network": "^2.0.9",
|
|
99
99
|
"@ledgerhq/logs": "^6.13.0",
|
|
100
100
|
"@ledgerhq/types-cryptoassets": "^7.23.0",
|
|
101
|
-
"@ledgerhq/types-live": "^6.73.0-
|
|
101
|
+
"@ledgerhq/types-live": "^6.73.0-nightly.1"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
104
|
"@types/invariant": "^2.2.2",
|
package/src/api/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Unit } from "@ledgerhq/types-cryptoassets";
|
|
2
|
+
|
|
1
3
|
export type BlockInfo = {
|
|
2
4
|
height: number;
|
|
3
5
|
hash?: string;
|
|
@@ -13,23 +15,37 @@ export type Asset<TokenInfo extends TokenInfoCommon = never> =
|
|
|
13
15
|
| { type: "native" }
|
|
14
16
|
| (TokenInfo extends never ? TokenInfo : { type: "token" } & TokenInfo);
|
|
15
17
|
|
|
16
|
-
export type Operation<
|
|
18
|
+
export type Operation<
|
|
19
|
+
AssetInfo extends Asset<TokenInfoCommon> = Asset<TokenInfoCommon>,
|
|
20
|
+
MemoType extends Memo = MemoNotSupported,
|
|
21
|
+
> = {
|
|
17
22
|
id: string;
|
|
18
23
|
type: string;
|
|
24
|
+
|
|
19
25
|
senders: string[];
|
|
20
26
|
recipients: string[];
|
|
27
|
+
|
|
21
28
|
value: bigint;
|
|
22
29
|
asset: AssetInfo;
|
|
23
|
-
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Optional memo associated with the operation.
|
|
33
|
+
* Use a `Memo` interface like `StringMemo<"text">`, `MapMemo<Kind, Value>`, or `MyMemo`.
|
|
34
|
+
* Defaults to `MemoNotSupported`.
|
|
35
|
+
*/
|
|
36
|
+
memo?: MemoType;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Arbitrary per-blockchain extra fields.
|
|
40
|
+
* This can include things like status, error messages, swap info, etc.
|
|
41
|
+
*/
|
|
24
42
|
details?: Record<string, unknown>;
|
|
43
|
+
|
|
25
44
|
tx: {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
fees: bigint;
|
|
31
|
-
// see BlockInfo.time comment
|
|
32
|
-
date: Date;
|
|
45
|
+
hash: string; // transaction hash
|
|
46
|
+
block: BlockInfo; // block metadata
|
|
47
|
+
fees: bigint; // network fees paid
|
|
48
|
+
date: Date; // tx date (may differ from block time)
|
|
33
49
|
};
|
|
34
50
|
};
|
|
35
51
|
|
|
@@ -40,26 +56,79 @@ export type Transaction = {
|
|
|
40
56
|
fee: bigint;
|
|
41
57
|
} & Record<string, unknown>; // Field containing dedicated value for each blockchain
|
|
42
58
|
|
|
59
|
+
// Other coins take differents parameters What do we want to do ?
|
|
60
|
+
export type Account = {
|
|
61
|
+
currencyName: string;
|
|
62
|
+
address: string;
|
|
63
|
+
balance: bigint;
|
|
64
|
+
currencyUnit: Unit;
|
|
65
|
+
};
|
|
66
|
+
|
|
43
67
|
export type Balance<AssetInfo extends Asset<TokenInfoCommon>> = {
|
|
44
68
|
value: bigint;
|
|
69
|
+
locked?: bigint;
|
|
45
70
|
asset: AssetInfo;
|
|
46
71
|
};
|
|
47
72
|
|
|
73
|
+
export interface Memo {
|
|
74
|
+
type: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// generic implementations that cover many coins (in coin-framework)
|
|
78
|
+
export interface MemoNotSupported extends Memo {
|
|
79
|
+
type: "none";
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Specialized version, not extending the above
|
|
83
|
+
export interface StringMemo<Kind extends string = "text"> extends Memo {
|
|
84
|
+
type: "string";
|
|
85
|
+
kind: Kind;
|
|
86
|
+
value: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface MapMemo<Kind extends string, Value> extends Memo {
|
|
90
|
+
type: "map";
|
|
91
|
+
memos: Map<Kind, Value>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface TypedMapMemo<KindToValueMap extends Record<string, unknown>> extends Memo {
|
|
95
|
+
type: "map";
|
|
96
|
+
memos: Map<keyof KindToValueMap, KindToValueMap[keyof KindToValueMap]>;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// FIXME: find better maybeMemo type without disabling the rule
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
101
|
+
type MaybeMemo<MemoType extends Memo> = MemoType extends MemoNotSupported ? {} : { memo: MemoType };
|
|
102
|
+
|
|
48
103
|
export type TransactionIntent<
|
|
49
104
|
AssetInfo extends Asset<TokenInfoCommon>,
|
|
50
|
-
|
|
51
|
-
Sender extends Record<string, string> | string = string,
|
|
105
|
+
MemoType extends Memo = MemoNotSupported,
|
|
52
106
|
> = {
|
|
53
107
|
type: string;
|
|
54
|
-
sender:
|
|
108
|
+
sender: string;
|
|
109
|
+
senderPublicKey?: string;
|
|
110
|
+
expiration?: number;
|
|
55
111
|
recipient: string;
|
|
56
112
|
amount: bigint;
|
|
57
113
|
asset: AssetInfo;
|
|
58
|
-
} &
|
|
114
|
+
} & MaybeMemo<MemoType>;
|
|
59
115
|
|
|
60
|
-
export type
|
|
116
|
+
export type TransactionValidation = {
|
|
117
|
+
errors: Record<string, Error>;
|
|
118
|
+
warnings: Record<string, Error>;
|
|
119
|
+
estimatedFees: bigint;
|
|
120
|
+
amount: bigint;
|
|
121
|
+
totalSpent: bigint;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export type FeeEstimation = {
|
|
61
125
|
value: bigint;
|
|
62
|
-
parameters?:
|
|
126
|
+
parameters?: {
|
|
127
|
+
storageLimit: bigint;
|
|
128
|
+
gasLimit: bigint;
|
|
129
|
+
// Optional gas price, only for Aptos (need to improve)
|
|
130
|
+
gasPrice?: bigint;
|
|
131
|
+
};
|
|
63
132
|
};
|
|
64
133
|
|
|
65
134
|
// TODO rename start to minHeight
|
|
@@ -69,19 +138,18 @@ export type FeeEstimation<FeeParameters extends Record<string, bigint> = never>
|
|
|
69
138
|
// limit is unused for now
|
|
70
139
|
// see design document at https://ledgerhq.atlassian.net/wiki/spaces/BE/pages/5446205788/coin-modules+lama-adapter+APIs+refinements
|
|
71
140
|
export type Pagination = { minHeight: number };
|
|
72
|
-
|
|
141
|
+
|
|
142
|
+
export type AlpacaApi<
|
|
73
143
|
AssetInfo extends Asset<TokenInfoCommon>,
|
|
74
|
-
|
|
75
|
-
Sender extends Record<string, string> | string = string,
|
|
76
|
-
FeeParameters extends Record<string, bigint> = never,
|
|
144
|
+
MemoType extends Memo = MemoNotSupported,
|
|
77
145
|
> = {
|
|
78
146
|
broadcast: (tx: string) => Promise<string>;
|
|
79
|
-
combine: (tx: string, signature: string, pubkey?: string) => string
|
|
147
|
+
combine: (tx: string, signature: string, pubkey?: string) => string | Promise<string>;
|
|
80
148
|
estimateFees: (
|
|
81
|
-
transactionIntent: TransactionIntent<AssetInfo,
|
|
82
|
-
) => Promise<FeeEstimation
|
|
149
|
+
transactionIntent: TransactionIntent<AssetInfo, MemoType>,
|
|
150
|
+
) => Promise<FeeEstimation>;
|
|
83
151
|
craftTransaction: (
|
|
84
|
-
transactionIntent: TransactionIntent<AssetInfo,
|
|
152
|
+
transactionIntent: TransactionIntent<AssetInfo, MemoType>,
|
|
85
153
|
customFees?: bigint,
|
|
86
154
|
) => Promise<string>;
|
|
87
155
|
getBalance: (address: string) => Promise<Balance<AssetInfo>[]>;
|
|
@@ -91,3 +159,12 @@ export type Api<
|
|
|
91
159
|
pagination: Pagination,
|
|
92
160
|
) => Promise<[Operation<AssetInfo>[], string]>;
|
|
93
161
|
};
|
|
162
|
+
|
|
163
|
+
export type BridgeApi = {
|
|
164
|
+
validateIntent: (account: Account, transaction: Transaction) => Promise<TransactionValidation>;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export type Api<
|
|
168
|
+
AssetInfo extends Asset<TokenInfoCommon>,
|
|
169
|
+
MemoType extends Memo = MemoNotSupported,
|
|
170
|
+
> = AlpacaApi<AssetInfo, MemoType> & BridgeApi;
|
package/src/config.ts
CHANGED
|
@@ -46,6 +46,10 @@ export type CurrencyConfig = {
|
|
|
46
46
|
|
|
47
47
|
export type CoinConfig<T extends CurrencyConfig> = (currency?: CryptoCurrency) => T;
|
|
48
48
|
|
|
49
|
+
export type SharedConfig = {
|
|
50
|
+
checkBlacklistAddress?: boolean;
|
|
51
|
+
};
|
|
52
|
+
|
|
49
53
|
function buildCoinConfig<T extends CurrencyConfig>() {
|
|
50
54
|
let coinConfig: CoinConfig<T> | undefined;
|
|
51
55
|
|