@1money/protocol-ts-sdk 1.0.16 → 1.1.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/.claude/settings.local.json +14 -2
- package/.env.integration.example +19 -0
- package/AGENTS.md +28 -0
- package/LICENSE +21 -0
- package/README.md +21 -55
- package/es/__integration__/config.d.ts +24 -0
- package/es/__integration__/helpers.d.ts +75 -0
- package/es/__integration__/setup.d.ts +26 -0
- package/es/api/accounts/index.d.ts +7 -1
- package/es/api/accounts/types.d.ts +4 -2
- package/es/api/checkpoints/index.d.ts +7 -1
- package/es/api/checkpoints/types.d.ts +4 -16
- package/es/api/index.js +45 -4
- package/es/api/tokens/index.d.ts +13 -1
- package/es/api/tokens/types.d.ts +27 -9
- package/es/api/transactions/index.d.ts +7 -2
- package/es/api/transactions/types.d.ts +149 -2
- package/es/client/core.d.ts +1 -1
- package/es/client/index.js +3 -3
- package/es/index.js +58 -8
- package/es/utils/index.js +13 -4
- package/lib/__integration__/config.d.ts +24 -0
- package/lib/__integration__/helpers.d.ts +75 -0
- package/lib/__integration__/setup.d.ts +26 -0
- package/lib/api/accounts/index.d.ts +7 -1
- package/lib/api/accounts/types.d.ts +4 -2
- package/lib/api/checkpoints/index.d.ts +7 -1
- package/lib/api/checkpoints/types.d.ts +4 -16
- package/lib/api/index.js +47 -6
- package/lib/api/tokens/index.d.ts +13 -1
- package/lib/api/tokens/types.d.ts +27 -9
- package/lib/api/transactions/index.d.ts +7 -2
- package/lib/api/transactions/types.d.ts +149 -2
- package/lib/client/core.d.ts +1 -1
- package/lib/client/index.js +5 -5
- package/lib/index.js +60 -10
- package/lib/utils/index.js +13 -4
- package/package.json +10 -1
- package/umd/1money-protocol-ts-sdk.min.js +2 -2
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
import { B256Schema
|
|
1
|
+
import { B256Schema } from '../types';
|
|
2
|
+
import type { Transaction, TransactionReceipt } from '../transactions/types';
|
|
2
3
|
export interface CheckpointNumberResponse {
|
|
3
4
|
number: number;
|
|
4
5
|
}
|
|
5
|
-
export
|
|
6
|
-
hash: B256Schema;
|
|
7
|
-
chain_id: number;
|
|
8
|
-
from: AddressSchema;
|
|
9
|
-
nonce: number;
|
|
10
|
-
fee: number;
|
|
11
|
-
signature: {
|
|
12
|
-
r: string;
|
|
13
|
-
s: string;
|
|
14
|
-
v: number;
|
|
15
|
-
};
|
|
16
|
-
checkpoint_hash?: B256Schema;
|
|
17
|
-
checkpoint_number?: number;
|
|
18
|
-
transaction_index?: number;
|
|
19
|
-
}
|
|
6
|
+
export type { Transaction };
|
|
20
7
|
export interface Header {
|
|
21
8
|
hash: B256Schema;
|
|
22
9
|
parent_hash: B256Schema;
|
|
@@ -31,3 +18,4 @@ export interface Checkpoint extends Header {
|
|
|
31
18
|
size?: number;
|
|
32
19
|
transactions: Transaction[] | B256Schema[];
|
|
33
20
|
}
|
|
21
|
+
export type CheckpointReceipts = TransactionReceipt[];
|
package/lib/api/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});require('viem'),require('@ethereumjs/rlp');var axios$1=require('axios');/******************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -354,7 +354,7 @@ var Request = /** @class */ (function () {
|
|
|
354
354
|
}
|
|
355
355
|
});
|
|
356
356
|
}); }).catch(function (err) { return __awaiter(_this, void 0, void 0, function () {
|
|
357
|
-
var
|
|
357
|
+
var data, status, headers, res, doLogin, e_3;
|
|
358
358
|
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
359
359
|
return __generator(this, function (_w) {
|
|
360
360
|
switch (_w.label) {
|
|
@@ -362,9 +362,9 @@ var Request = /** @class */ (function () {
|
|
|
362
362
|
if (isTimeout)
|
|
363
363
|
return [2 /*return*/];
|
|
364
364
|
cleanup();
|
|
365
|
-
|
|
366
|
-
status = (_q = (_p = err.
|
|
367
|
-
|
|
365
|
+
data = (_b = (_a = err.response) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : {};
|
|
366
|
+
console.error("[1Money client]: Error(".concat((_c = err.status) !== null && _c !== void 0 ? _c : 500, ", ").concat((_d = err.code) !== null && _d !== void 0 ? _d : 'UNKNOWN', "), Message: ").concat(err.message, ", Config: ").concat((_f = err.config) === null || _f === void 0 ? void 0 : _f.method, ", ").concat((_h = (_g = err.config) === null || _g === void 0 ? void 0 : _g.baseURL) !== null && _h !== void 0 ? _h : '').concat((_k = (_j = err.config) === null || _j === void 0 ? void 0 : _j.url) !== null && _k !== void 0 ? _k : '', ", ").concat(JSON.stringify((_o = (_l = err.config) === null || _l === void 0 ? void 0 : _l.headers) !== null && _o !== void 0 ? _o : {}), ", Request: ").concat(JSON.stringify((_q = (_p = err.config) === null || _p === void 0 ? void 0 : _p.data) !== null && _q !== void 0 ? _q : {}), ", Response: ").concat(JSON.stringify(data), ";"));
|
|
367
|
+
status = (_s = (_r = err.response) === null || _r === void 0 ? void 0 : _r.status) !== null && _s !== void 0 ? _s : 500;
|
|
368
368
|
headers = (_u = (_t = err.response) === null || _t === void 0 ? void 0 : _t.headers) !== null && _u !== void 0 ? _u : {};
|
|
369
369
|
_w.label = 1;
|
|
370
370
|
case 1:
|
|
@@ -426,6 +426,14 @@ var accountsApi = {
|
|
|
426
426
|
getNonce: function (address) {
|
|
427
427
|
return get("".concat(API_PREFIX$4, "/nonce?address=").concat(address), { withCredentials: false });
|
|
428
428
|
},
|
|
429
|
+
/**
|
|
430
|
+
* Get account bbnonce
|
|
431
|
+
* @param address Address of the account to lookup nonce for
|
|
432
|
+
* @returns Promise with bbnonce info response
|
|
433
|
+
*/
|
|
434
|
+
getBbNonce: function (address) {
|
|
435
|
+
return get("".concat(API_PREFIX$4, "/bbnonce?address=").concat(address), { withCredentials: false });
|
|
436
|
+
},
|
|
429
437
|
/**
|
|
430
438
|
* Get associated token account
|
|
431
439
|
* @param address Address of the account to lookup associated token account for
|
|
@@ -466,6 +474,14 @@ var checkpointsApi = {
|
|
|
466
474
|
getByNumber: function (number, full) {
|
|
467
475
|
if (full === void 0) { full = false; }
|
|
468
476
|
return get("".concat(API_PREFIX$3, "/by_number?number=").concat(number, "&full=").concat(full), { withCredentials: false });
|
|
477
|
+
},
|
|
478
|
+
/**
|
|
479
|
+
* Get checkpoint receipts by number
|
|
480
|
+
* @param number Number of the checkpoint to lookup
|
|
481
|
+
* @returns Promise with checkpoint receipts response
|
|
482
|
+
*/
|
|
483
|
+
getReceiptsByNumber: function (number) {
|
|
484
|
+
return get("".concat(API_PREFIX$3, "/receipts/by_number?number=").concat(number), { withCredentials: false });
|
|
469
485
|
}
|
|
470
486
|
};var API_PREFIX$2 = "/".concat(API_VERSION, "/tokens");
|
|
471
487
|
/**
|
|
@@ -543,6 +559,22 @@ var tokensApi = {
|
|
|
543
559
|
*/
|
|
544
560
|
updateMetadata: function (payload) {
|
|
545
561
|
return post("".concat(API_PREFIX$2, "/update_metadata"), payload, { withCredentials: false });
|
|
562
|
+
},
|
|
563
|
+
/**
|
|
564
|
+
* Bridge and mint tokens
|
|
565
|
+
* @param payload Token bridge and mint request payload
|
|
566
|
+
* @returns Promise with transaction hash response
|
|
567
|
+
*/
|
|
568
|
+
bridgeAndMint: function (payload) {
|
|
569
|
+
return post("".concat(API_PREFIX$2, "/bridge_and_mint"), payload, { withCredentials: false });
|
|
570
|
+
},
|
|
571
|
+
/**
|
|
572
|
+
* Burn and bridge tokens
|
|
573
|
+
* @param payload Token burn and bridge request payload
|
|
574
|
+
* @returns Promise with transaction hash response
|
|
575
|
+
*/
|
|
576
|
+
burnAndBridge: function (payload) {
|
|
577
|
+
return post("".concat(API_PREFIX$2, "/burn_and_bridge"), payload, { withCredentials: false });
|
|
546
578
|
}
|
|
547
579
|
};var API_PREFIX$1 = "/".concat(API_VERSION, "/transactions");
|
|
548
580
|
/**
|
|
@@ -565,6 +597,14 @@ var transactionsApi = {
|
|
|
565
597
|
getReceiptByHash: function (hash) {
|
|
566
598
|
return get("".concat(API_PREFIX$1, "/receipt/by_hash?hash=").concat(hash), { withCredentials: false });
|
|
567
599
|
},
|
|
600
|
+
/**
|
|
601
|
+
* Get finalized transaction by hash
|
|
602
|
+
* @param hash Hash of the transaction to lookup
|
|
603
|
+
* @returns Promise with finalized transaction receipt response
|
|
604
|
+
*/
|
|
605
|
+
getFinalizedByHash: function (hash) {
|
|
606
|
+
return get("".concat(API_PREFIX$1, "/finalized/by_hash?hash=").concat(hash), { withCredentials: false });
|
|
607
|
+
},
|
|
568
608
|
/**
|
|
569
609
|
* Estimate transaction fee
|
|
570
610
|
* @param from Address of the transaction author
|
|
@@ -602,11 +642,12 @@ var chainApi = {
|
|
|
602
642
|
};// Authority types
|
|
603
643
|
exports.AuthorityType=void 0;
|
|
604
644
|
(function (AuthorityType) {
|
|
605
|
-
AuthorityType["MasterMint"] = "
|
|
645
|
+
AuthorityType["MasterMint"] = "MasterMintBurn";
|
|
606
646
|
AuthorityType["MintBurnTokens"] = "MintBurnTokens";
|
|
607
647
|
AuthorityType["Pause"] = "Pause";
|
|
608
648
|
AuthorityType["ManageList"] = "ManageList";
|
|
609
649
|
AuthorityType["UpdateMetadata"] = "UpdateMetadata";
|
|
650
|
+
AuthorityType["Bridge"] = "Bridge";
|
|
610
651
|
})(exports.AuthorityType || (exports.AuthorityType = {}));
|
|
611
652
|
exports.AuthorityAction=void 0;
|
|
612
653
|
(function (AuthorityAction) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Hash, HashWithToken } from '../../api/types';
|
|
2
|
-
import type { MintInfo, TokenManageListPayload, TokenBurnPayload, TokenAuthorityPayload, TokenIssuePayload, TokenMintPayload, TokenPausePayload, TokenMetadataPayload } from './types';
|
|
2
|
+
import type { MintInfo, TokenManageListPayload, TokenBurnPayload, TokenAuthorityPayload, TokenIssuePayload, TokenMintPayload, TokenPausePayload, TokenMetadataPayload, TokenBridgeAndMintPayload, TokenBurnAndBridgePayload } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Tokens API methods
|
|
5
5
|
*/
|
|
@@ -58,5 +58,17 @@ export declare const tokensApi: {
|
|
|
58
58
|
* @returns Promise with transaction hash response
|
|
59
59
|
*/
|
|
60
60
|
updateMetadata: (payload: TokenMetadataPayload) => import("../../client/index.js").PromiseWrapper<"custom", Hash, Hash, Hash, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | Hash, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<Hash>;
|
|
61
|
+
/**
|
|
62
|
+
* Bridge and mint tokens
|
|
63
|
+
* @param payload Token bridge and mint request payload
|
|
64
|
+
* @returns Promise with transaction hash response
|
|
65
|
+
*/
|
|
66
|
+
bridgeAndMint: (payload: TokenBridgeAndMintPayload) => import("../../client/index.js").PromiseWrapper<"custom", Hash, Hash, Hash, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | Hash, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<Hash>;
|
|
67
|
+
/**
|
|
68
|
+
* Burn and bridge tokens
|
|
69
|
+
* @param payload Token burn and bridge request payload
|
|
70
|
+
* @returns Promise with transaction hash response
|
|
71
|
+
*/
|
|
72
|
+
burnAndBridge: (payload: TokenBurnAndBridgePayload) => import("../../client/index.js").PromiseWrapper<"custom", Hash, Hash, Hash, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | Hash, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<Hash>;
|
|
61
73
|
};
|
|
62
74
|
export default tokensApi;
|
|
@@ -23,6 +23,7 @@ export interface MintInfo {
|
|
|
23
23
|
black_list: AddressSchema[];
|
|
24
24
|
white_list: AddressSchema[];
|
|
25
25
|
metadata_update_authorities: AddressSchema[];
|
|
26
|
+
bridge_mint_authorities: AddressSchema[];
|
|
26
27
|
supply: U256Schema;
|
|
27
28
|
decimals: number;
|
|
28
29
|
is_paused: boolean;
|
|
@@ -34,11 +35,12 @@ export interface KeyValuePair {
|
|
|
34
35
|
value: string;
|
|
35
36
|
}
|
|
36
37
|
export declare enum AuthorityType {
|
|
37
|
-
MasterMint = "
|
|
38
|
+
MasterMint = "MasterMintBurn",
|
|
38
39
|
MintBurnTokens = "MintBurnTokens",
|
|
39
40
|
Pause = "Pause",
|
|
40
41
|
ManageList = "ManageList",
|
|
41
|
-
UpdateMetadata = "UpdateMetadata"
|
|
42
|
+
UpdateMetadata = "UpdateMetadata",
|
|
43
|
+
Bridge = "Bridge"
|
|
42
44
|
}
|
|
43
45
|
export declare enum AuthorityAction {
|
|
44
46
|
Grant = "Grant",
|
|
@@ -55,7 +57,6 @@ export declare enum PauseAction {
|
|
|
55
57
|
export interface RestSignature extends Signature {
|
|
56
58
|
}
|
|
57
59
|
export interface TokenManageListPayload {
|
|
58
|
-
recent_checkpoint: number;
|
|
59
60
|
chain_id: number;
|
|
60
61
|
nonce: number;
|
|
61
62
|
action: ManageListAction;
|
|
@@ -64,7 +65,6 @@ export interface TokenManageListPayload {
|
|
|
64
65
|
signature: RestSignature;
|
|
65
66
|
}
|
|
66
67
|
export interface TokenBurnPayload {
|
|
67
|
-
recent_checkpoint: number;
|
|
68
68
|
chain_id: number;
|
|
69
69
|
nonce: number;
|
|
70
70
|
recipient: string;
|
|
@@ -73,7 +73,6 @@ export interface TokenBurnPayload {
|
|
|
73
73
|
signature: RestSignature;
|
|
74
74
|
}
|
|
75
75
|
export interface TokenAuthorityPayload {
|
|
76
|
-
recent_checkpoint: number;
|
|
77
76
|
chain_id: number;
|
|
78
77
|
nonce: number;
|
|
79
78
|
action: AuthorityAction;
|
|
@@ -84,7 +83,6 @@ export interface TokenAuthorityPayload {
|
|
|
84
83
|
signature: RestSignature;
|
|
85
84
|
}
|
|
86
85
|
export interface TokenIssuePayload {
|
|
87
|
-
recent_checkpoint: number;
|
|
88
86
|
chain_id: number;
|
|
89
87
|
nonce: number;
|
|
90
88
|
symbol: string;
|
|
@@ -95,7 +93,6 @@ export interface TokenIssuePayload {
|
|
|
95
93
|
signature: RestSignature;
|
|
96
94
|
}
|
|
97
95
|
export interface TokenMintPayload {
|
|
98
|
-
recent_checkpoint: number;
|
|
99
96
|
chain_id: number;
|
|
100
97
|
nonce: number;
|
|
101
98
|
recipient: string;
|
|
@@ -104,7 +101,6 @@ export interface TokenMintPayload {
|
|
|
104
101
|
signature: RestSignature;
|
|
105
102
|
}
|
|
106
103
|
export interface TokenPausePayload {
|
|
107
|
-
recent_checkpoint: number;
|
|
108
104
|
chain_id: number;
|
|
109
105
|
nonce: number;
|
|
110
106
|
action: PauseAction;
|
|
@@ -112,7 +108,6 @@ export interface TokenPausePayload {
|
|
|
112
108
|
signature: RestSignature;
|
|
113
109
|
}
|
|
114
110
|
export interface TokenMetadataPayload {
|
|
115
|
-
recent_checkpoint: number;
|
|
116
111
|
chain_id: number;
|
|
117
112
|
nonce: number;
|
|
118
113
|
name: string;
|
|
@@ -121,3 +116,26 @@ export interface TokenMetadataPayload {
|
|
|
121
116
|
additional_metadata: KeyValuePair[];
|
|
122
117
|
signature: RestSignature;
|
|
123
118
|
}
|
|
119
|
+
export interface TokenBridgeAndMintPayload {
|
|
120
|
+
chain_id: number;
|
|
121
|
+
nonce: number;
|
|
122
|
+
recipient: string;
|
|
123
|
+
value: string;
|
|
124
|
+
token: string;
|
|
125
|
+
source_chain_id: number;
|
|
126
|
+
source_tx_hash: string;
|
|
127
|
+
bridge_metadata: string;
|
|
128
|
+
signature: RestSignature;
|
|
129
|
+
}
|
|
130
|
+
export interface TokenBurnAndBridgePayload {
|
|
131
|
+
bridge_metadata: string;
|
|
132
|
+
chain_id: number;
|
|
133
|
+
destination_address: string;
|
|
134
|
+
destination_chain_id: number;
|
|
135
|
+
escrow_fee: string;
|
|
136
|
+
nonce: number;
|
|
137
|
+
sender: string;
|
|
138
|
+
token: string;
|
|
139
|
+
value: string;
|
|
140
|
+
signature: RestSignature;
|
|
141
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Hash } from '../../api/types';
|
|
2
|
-
import type { Transaction } from '
|
|
3
|
-
import type { TransactionReceipt, EstimateFee, PaymentPayload } from './types';
|
|
2
|
+
import type { EstimateFee, PaymentPayload, Transaction, TransactionReceipt, FinalizedTransactionReceipt } from './types';
|
|
4
3
|
/**
|
|
5
4
|
* Transactions API methods
|
|
6
5
|
*/
|
|
@@ -17,6 +16,12 @@ export declare const transactionsApi: {
|
|
|
17
16
|
* @returns Promise with transaction receipt response
|
|
18
17
|
*/
|
|
19
18
|
getReceiptByHash: (hash: string) => import("../../client/index.js").PromiseWrapper<"custom", TransactionReceipt, TransactionReceipt, TransactionReceipt, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | TransactionReceipt, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<TransactionReceipt>;
|
|
19
|
+
/**
|
|
20
|
+
* Get finalized transaction by hash
|
|
21
|
+
* @param hash Hash of the transaction to lookup
|
|
22
|
+
* @returns Promise with finalized transaction receipt response
|
|
23
|
+
*/
|
|
24
|
+
getFinalizedByHash: (hash: string) => import("../../client/index.js").PromiseWrapper<"custom", FinalizedTransactionReceipt, FinalizedTransactionReceipt, FinalizedTransactionReceipt, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | FinalizedTransactionReceipt, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<FinalizedTransactionReceipt>;
|
|
20
25
|
/**
|
|
21
26
|
* Estimate transaction fee
|
|
22
27
|
* @param from Address of the transaction author
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { AuthorityType, RestSignature } from '../tokens/types';
|
|
1
2
|
import { AddressSchema, B256Schema } from '../types';
|
|
2
|
-
import { RestSignature } from '../tokens/types';
|
|
3
3
|
export interface TransactionReceipt {
|
|
4
4
|
success: boolean;
|
|
5
5
|
transaction_hash: B256Schema;
|
|
@@ -10,11 +10,14 @@ export interface TransactionReceipt {
|
|
|
10
10
|
to?: AddressSchema;
|
|
11
11
|
token_address?: AddressSchema;
|
|
12
12
|
}
|
|
13
|
+
export interface FinalizedTransactionReceipt extends TransactionReceipt {
|
|
14
|
+
epoch: number;
|
|
15
|
+
counter_signatures: RestSignature[];
|
|
16
|
+
}
|
|
13
17
|
export interface EstimateFee {
|
|
14
18
|
fee: string;
|
|
15
19
|
}
|
|
16
20
|
export interface PaymentPayload {
|
|
17
|
-
recent_checkpoint: number;
|
|
18
21
|
chain_id: number;
|
|
19
22
|
nonce: number;
|
|
20
23
|
recipient: AddressSchema;
|
|
@@ -22,3 +25,147 @@ export interface PaymentPayload {
|
|
|
22
25
|
token: AddressSchema;
|
|
23
26
|
signature: RestSignature;
|
|
24
27
|
}
|
|
28
|
+
export interface TokenCreateData {
|
|
29
|
+
decimals: number;
|
|
30
|
+
is_private: boolean;
|
|
31
|
+
master_authority: AddressSchema;
|
|
32
|
+
name: string;
|
|
33
|
+
symbol: string;
|
|
34
|
+
}
|
|
35
|
+
export interface TokenTransferData {
|
|
36
|
+
recipient: AddressSchema;
|
|
37
|
+
token: AddressSchema;
|
|
38
|
+
value: string;
|
|
39
|
+
}
|
|
40
|
+
export interface TokenMintData {
|
|
41
|
+
recipient: AddressSchema;
|
|
42
|
+
token: AddressSchema;
|
|
43
|
+
value: string;
|
|
44
|
+
}
|
|
45
|
+
export interface TokenGrantAuthorityData {
|
|
46
|
+
authority_address: AddressSchema;
|
|
47
|
+
authority_type: AuthorityType;
|
|
48
|
+
token: AddressSchema;
|
|
49
|
+
value: string;
|
|
50
|
+
}
|
|
51
|
+
export interface TokenRevokeAuthorityData {
|
|
52
|
+
authority_address: AddressSchema;
|
|
53
|
+
authority_type: AuthorityType;
|
|
54
|
+
token: AddressSchema;
|
|
55
|
+
value: string;
|
|
56
|
+
}
|
|
57
|
+
export interface TokenBlacklistAccountData {
|
|
58
|
+
address: AddressSchema;
|
|
59
|
+
token: AddressSchema;
|
|
60
|
+
}
|
|
61
|
+
export interface TokenWhitelistAccountData {
|
|
62
|
+
address: AddressSchema;
|
|
63
|
+
token: AddressSchema;
|
|
64
|
+
}
|
|
65
|
+
export interface TokenBridgeAndMintData {
|
|
66
|
+
bridge_metadata: string | null;
|
|
67
|
+
recipient: AddressSchema;
|
|
68
|
+
source_chain_id: number;
|
|
69
|
+
source_tx_hash: string;
|
|
70
|
+
token: AddressSchema;
|
|
71
|
+
value: string;
|
|
72
|
+
}
|
|
73
|
+
export interface TokenBurnData {
|
|
74
|
+
recipient: AddressSchema;
|
|
75
|
+
token: AddressSchema;
|
|
76
|
+
value: string;
|
|
77
|
+
}
|
|
78
|
+
export interface TokenBurnAndBridgeData {
|
|
79
|
+
bridge_metadata: string | null;
|
|
80
|
+
destination_address: AddressSchema;
|
|
81
|
+
destination_chain_id: number;
|
|
82
|
+
escrow_fee: string;
|
|
83
|
+
sender: AddressSchema;
|
|
84
|
+
token: AddressSchema;
|
|
85
|
+
value: string;
|
|
86
|
+
}
|
|
87
|
+
export interface TokenCloseAccountData {
|
|
88
|
+
token: AddressSchema;
|
|
89
|
+
}
|
|
90
|
+
export interface TokenPauseData {
|
|
91
|
+
token: AddressSchema;
|
|
92
|
+
}
|
|
93
|
+
export interface TokenUpdateMetadataData {
|
|
94
|
+
metadata: {
|
|
95
|
+
name: string;
|
|
96
|
+
uri: string;
|
|
97
|
+
additional_metadata: Array<{
|
|
98
|
+
key: string;
|
|
99
|
+
value: string;
|
|
100
|
+
}>;
|
|
101
|
+
};
|
|
102
|
+
token: AddressSchema;
|
|
103
|
+
}
|
|
104
|
+
export interface RawData {
|
|
105
|
+
input: string;
|
|
106
|
+
token: AddressSchema;
|
|
107
|
+
}
|
|
108
|
+
export interface TokenUnpauseData {
|
|
109
|
+
token: AddressSchema;
|
|
110
|
+
}
|
|
111
|
+
interface BaseTransaction {
|
|
112
|
+
hash: B256Schema;
|
|
113
|
+
checkpoint_hash?: B256Schema;
|
|
114
|
+
checkpoint_number?: number;
|
|
115
|
+
transaction_index?: number;
|
|
116
|
+
chain_id: number;
|
|
117
|
+
from: AddressSchema;
|
|
118
|
+
nonce: number;
|
|
119
|
+
signature: {
|
|
120
|
+
r: string;
|
|
121
|
+
s: string;
|
|
122
|
+
v: number;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
export type Transaction = (BaseTransaction & {
|
|
126
|
+
transaction_type: 'TokenCreate';
|
|
127
|
+
data: TokenCreateData;
|
|
128
|
+
}) | (BaseTransaction & {
|
|
129
|
+
transaction_type: 'TokenTransfer';
|
|
130
|
+
data: TokenTransferData;
|
|
131
|
+
}) | (BaseTransaction & {
|
|
132
|
+
transaction_type: 'TokenMint';
|
|
133
|
+
data: TokenMintData;
|
|
134
|
+
}) | (BaseTransaction & {
|
|
135
|
+
transaction_type: 'TokenGrantAuthority';
|
|
136
|
+
data: TokenGrantAuthorityData;
|
|
137
|
+
}) | (BaseTransaction & {
|
|
138
|
+
transaction_type: 'TokenRevokeAuthority';
|
|
139
|
+
data: TokenRevokeAuthorityData;
|
|
140
|
+
}) | (BaseTransaction & {
|
|
141
|
+
transaction_type: 'TokenBlacklistAccount';
|
|
142
|
+
data: TokenBlacklistAccountData;
|
|
143
|
+
}) | (BaseTransaction & {
|
|
144
|
+
transaction_type: 'TokenWhitelistAccount';
|
|
145
|
+
data: TokenWhitelistAccountData;
|
|
146
|
+
}) | (BaseTransaction & {
|
|
147
|
+
transaction_type: 'TokenBridgeAndMint';
|
|
148
|
+
data: TokenBridgeAndMintData;
|
|
149
|
+
}) | (BaseTransaction & {
|
|
150
|
+
transaction_type: 'TokenBurn';
|
|
151
|
+
data: TokenBurnData;
|
|
152
|
+
}) | (BaseTransaction & {
|
|
153
|
+
transaction_type: 'TokenBurnAndBridge';
|
|
154
|
+
data: TokenBurnAndBridgeData;
|
|
155
|
+
}) | (BaseTransaction & {
|
|
156
|
+
transaction_type: 'TokenCloseAccount';
|
|
157
|
+
data: TokenCloseAccountData;
|
|
158
|
+
}) | (BaseTransaction & {
|
|
159
|
+
transaction_type: 'TokenPause';
|
|
160
|
+
data: TokenPauseData;
|
|
161
|
+
}) | (BaseTransaction & {
|
|
162
|
+
transaction_type: 'TokenUnpause';
|
|
163
|
+
data: TokenUnpauseData;
|
|
164
|
+
}) | (BaseTransaction & {
|
|
165
|
+
transaction_type: 'TokenUpdateMetadata';
|
|
166
|
+
data: TokenUpdateMetadataData;
|
|
167
|
+
}) | (BaseTransaction & {
|
|
168
|
+
transaction_type: 'Raw';
|
|
169
|
+
data: RawData;
|
|
170
|
+
});
|
|
171
|
+
export {};
|
package/lib/client/core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AxiosRequestConfig, AxiosRequestHeaders, AxiosResponseHeaders, AxiosStatic, RawAxiosRequestHeaders, RawAxiosResponseHeaders } from 'axios';
|
|
2
2
|
export type ParsedError<T extends string = string> = {
|
|
3
3
|
name: T;
|
|
4
4
|
message: string;
|
package/lib/client/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});require('viem'),require('@ethereumjs/rlp');var axios$1=require('axios');/******************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -354,7 +354,7 @@ var Request = /** @class */ (function () {
|
|
|
354
354
|
}
|
|
355
355
|
});
|
|
356
356
|
}); }).catch(function (err) { return __awaiter(_this, void 0, void 0, function () {
|
|
357
|
-
var
|
|
357
|
+
var data, status, headers, res, doLogin, e_3;
|
|
358
358
|
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
359
359
|
return __generator(this, function (_w) {
|
|
360
360
|
switch (_w.label) {
|
|
@@ -362,9 +362,9 @@ var Request = /** @class */ (function () {
|
|
|
362
362
|
if (isTimeout)
|
|
363
363
|
return [2 /*return*/];
|
|
364
364
|
cleanup();
|
|
365
|
-
|
|
366
|
-
status = (_q = (_p = err.
|
|
367
|
-
|
|
365
|
+
data = (_b = (_a = err.response) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : {};
|
|
366
|
+
console.error("[1Money client]: Error(".concat((_c = err.status) !== null && _c !== void 0 ? _c : 500, ", ").concat((_d = err.code) !== null && _d !== void 0 ? _d : 'UNKNOWN', "), Message: ").concat(err.message, ", Config: ").concat((_f = err.config) === null || _f === void 0 ? void 0 : _f.method, ", ").concat((_h = (_g = err.config) === null || _g === void 0 ? void 0 : _g.baseURL) !== null && _h !== void 0 ? _h : '').concat((_k = (_j = err.config) === null || _j === void 0 ? void 0 : _j.url) !== null && _k !== void 0 ? _k : '', ", ").concat(JSON.stringify((_o = (_l = err.config) === null || _l === void 0 ? void 0 : _l.headers) !== null && _o !== void 0 ? _o : {}), ", Request: ").concat(JSON.stringify((_q = (_p = err.config) === null || _p === void 0 ? void 0 : _p.data) !== null && _q !== void 0 ? _q : {}), ", Response: ").concat(JSON.stringify(data), ";"));
|
|
367
|
+
status = (_s = (_r = err.response) === null || _r === void 0 ? void 0 : _r.status) !== null && _s !== void 0 ? _s : 500;
|
|
368
368
|
headers = (_u = (_t = err.response) === null || _t === void 0 ? void 0 : _t.headers) !== null && _u !== void 0 ? _u : {};
|
|
369
369
|
_w.label = 1;
|
|
370
370
|
case 1:
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var viem=require('viem'),rlp=require('@ethereumjs/rlp'),axios$1=require('axios');/******************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -828,9 +828,10 @@ function encodePayload(payload) {
|
|
|
828
828
|
// hex-encoded data → raw bytes
|
|
829
829
|
return viem.hexToBytes(v);
|
|
830
830
|
}
|
|
831
|
-
else if (
|
|
831
|
+
else if (/^\d+$/.test(v)) {
|
|
832
832
|
// number-like string → hex → bytes
|
|
833
|
-
|
|
833
|
+
// Use BigInt for large numbers to avoid overflow
|
|
834
|
+
return v === '0' ? new Uint8Array([]) : viem.hexToBytes(viem.numberToHex(BigInt(v)));
|
|
834
835
|
}
|
|
835
836
|
else {
|
|
836
837
|
// plain string → UTF-8 bytes
|
|
@@ -896,8 +897,16 @@ function toHex(value) {
|
|
|
896
897
|
case 'bigint':
|
|
897
898
|
return viem.numberToHex(value);
|
|
898
899
|
case 'string':
|
|
899
|
-
|
|
900
|
-
|
|
900
|
+
// Only accept valid integer strings (no decimals, no whitespace, no empty)
|
|
901
|
+
if (/^-?\d+$/.test(value)) {
|
|
902
|
+
// Use BigInt for potentially large numbers to avoid overflow
|
|
903
|
+
try {
|
|
904
|
+
return viem.numberToHex(BigInt(value));
|
|
905
|
+
}
|
|
906
|
+
catch (_a) {
|
|
907
|
+
return viem.numberToHex(+value);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
901
910
|
return viem.stringToHex(value);
|
|
902
911
|
case 'uint8array':
|
|
903
912
|
case 'uint16array':
|
|
@@ -1227,7 +1236,7 @@ var Request = /** @class */ (function () {
|
|
|
1227
1236
|
}
|
|
1228
1237
|
});
|
|
1229
1238
|
}); }).catch(function (err) { return __awaiter(_this, void 0, void 0, function () {
|
|
1230
|
-
var
|
|
1239
|
+
var data, status, headers, res, doLogin, e_3;
|
|
1231
1240
|
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
1232
1241
|
return __generator(this, function (_w) {
|
|
1233
1242
|
switch (_w.label) {
|
|
@@ -1235,9 +1244,9 @@ var Request = /** @class */ (function () {
|
|
|
1235
1244
|
if (isTimeout)
|
|
1236
1245
|
return [2 /*return*/];
|
|
1237
1246
|
cleanup();
|
|
1238
|
-
|
|
1239
|
-
status = (_q = (_p = err.
|
|
1240
|
-
|
|
1247
|
+
data = (_b = (_a = err.response) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : {};
|
|
1248
|
+
console.error("[1Money client]: Error(".concat((_c = err.status) !== null && _c !== void 0 ? _c : 500, ", ").concat((_d = err.code) !== null && _d !== void 0 ? _d : 'UNKNOWN', "), Message: ").concat(err.message, ", Config: ").concat((_f = err.config) === null || _f === void 0 ? void 0 : _f.method, ", ").concat((_h = (_g = err.config) === null || _g === void 0 ? void 0 : _g.baseURL) !== null && _h !== void 0 ? _h : '').concat((_k = (_j = err.config) === null || _j === void 0 ? void 0 : _j.url) !== null && _k !== void 0 ? _k : '', ", ").concat(JSON.stringify((_o = (_l = err.config) === null || _l === void 0 ? void 0 : _l.headers) !== null && _o !== void 0 ? _o : {}), ", Request: ").concat(JSON.stringify((_q = (_p = err.config) === null || _p === void 0 ? void 0 : _p.data) !== null && _q !== void 0 ? _q : {}), ", Response: ").concat(JSON.stringify(data), ";"));
|
|
1249
|
+
status = (_s = (_r = err.response) === null || _r === void 0 ? void 0 : _r.status) !== null && _s !== void 0 ? _s : 500;
|
|
1241
1250
|
headers = (_u = (_t = err.response) === null || _t === void 0 ? void 0 : _t.headers) !== null && _u !== void 0 ? _u : {};
|
|
1242
1251
|
_w.label = 1;
|
|
1243
1252
|
case 1:
|
|
@@ -1322,6 +1331,14 @@ var accountsApi = {
|
|
|
1322
1331
|
getNonce: function (address) {
|
|
1323
1332
|
return get("".concat(API_PREFIX$4, "/nonce?address=").concat(address), { withCredentials: false });
|
|
1324
1333
|
},
|
|
1334
|
+
/**
|
|
1335
|
+
* Get account bbnonce
|
|
1336
|
+
* @param address Address of the account to lookup nonce for
|
|
1337
|
+
* @returns Promise with bbnonce info response
|
|
1338
|
+
*/
|
|
1339
|
+
getBbNonce: function (address) {
|
|
1340
|
+
return get("".concat(API_PREFIX$4, "/bbnonce?address=").concat(address), { withCredentials: false });
|
|
1341
|
+
},
|
|
1325
1342
|
/**
|
|
1326
1343
|
* Get associated token account
|
|
1327
1344
|
* @param address Address of the account to lookup associated token account for
|
|
@@ -1362,6 +1379,14 @@ var checkpointsApi = {
|
|
|
1362
1379
|
getByNumber: function (number, full) {
|
|
1363
1380
|
if (full === void 0) { full = false; }
|
|
1364
1381
|
return get("".concat(API_PREFIX$3, "/by_number?number=").concat(number, "&full=").concat(full), { withCredentials: false });
|
|
1382
|
+
},
|
|
1383
|
+
/**
|
|
1384
|
+
* Get checkpoint receipts by number
|
|
1385
|
+
* @param number Number of the checkpoint to lookup
|
|
1386
|
+
* @returns Promise with checkpoint receipts response
|
|
1387
|
+
*/
|
|
1388
|
+
getReceiptsByNumber: function (number) {
|
|
1389
|
+
return get("".concat(API_PREFIX$3, "/receipts/by_number?number=").concat(number), { withCredentials: false });
|
|
1365
1390
|
}
|
|
1366
1391
|
};var API_PREFIX$2 = "/".concat(API_VERSION, "/tokens");
|
|
1367
1392
|
/**
|
|
@@ -1439,6 +1464,22 @@ var tokensApi = {
|
|
|
1439
1464
|
*/
|
|
1440
1465
|
updateMetadata: function (payload) {
|
|
1441
1466
|
return post("".concat(API_PREFIX$2, "/update_metadata"), payload, { withCredentials: false });
|
|
1467
|
+
},
|
|
1468
|
+
/**
|
|
1469
|
+
* Bridge and mint tokens
|
|
1470
|
+
* @param payload Token bridge and mint request payload
|
|
1471
|
+
* @returns Promise with transaction hash response
|
|
1472
|
+
*/
|
|
1473
|
+
bridgeAndMint: function (payload) {
|
|
1474
|
+
return post("".concat(API_PREFIX$2, "/bridge_and_mint"), payload, { withCredentials: false });
|
|
1475
|
+
},
|
|
1476
|
+
/**
|
|
1477
|
+
* Burn and bridge tokens
|
|
1478
|
+
* @param payload Token burn and bridge request payload
|
|
1479
|
+
* @returns Promise with transaction hash response
|
|
1480
|
+
*/
|
|
1481
|
+
burnAndBridge: function (payload) {
|
|
1482
|
+
return post("".concat(API_PREFIX$2, "/burn_and_bridge"), payload, { withCredentials: false });
|
|
1442
1483
|
}
|
|
1443
1484
|
};var API_PREFIX$1 = "/".concat(API_VERSION, "/transactions");
|
|
1444
1485
|
/**
|
|
@@ -1461,6 +1502,14 @@ var transactionsApi = {
|
|
|
1461
1502
|
getReceiptByHash: function (hash) {
|
|
1462
1503
|
return get("".concat(API_PREFIX$1, "/receipt/by_hash?hash=").concat(hash), { withCredentials: false });
|
|
1463
1504
|
},
|
|
1505
|
+
/**
|
|
1506
|
+
* Get finalized transaction by hash
|
|
1507
|
+
* @param hash Hash of the transaction to lookup
|
|
1508
|
+
* @returns Promise with finalized transaction receipt response
|
|
1509
|
+
*/
|
|
1510
|
+
getFinalizedByHash: function (hash) {
|
|
1511
|
+
return get("".concat(API_PREFIX$1, "/finalized/by_hash?hash=").concat(hash), { withCredentials: false });
|
|
1512
|
+
},
|
|
1464
1513
|
/**
|
|
1465
1514
|
* Estimate transaction fee
|
|
1466
1515
|
* @param from Address of the transaction author
|
|
@@ -1498,11 +1547,12 @@ var chainApi = {
|
|
|
1498
1547
|
};// Authority types
|
|
1499
1548
|
var AuthorityType;
|
|
1500
1549
|
(function (AuthorityType) {
|
|
1501
|
-
AuthorityType["MasterMint"] = "
|
|
1550
|
+
AuthorityType["MasterMint"] = "MasterMintBurn";
|
|
1502
1551
|
AuthorityType["MintBurnTokens"] = "MintBurnTokens";
|
|
1503
1552
|
AuthorityType["Pause"] = "Pause";
|
|
1504
1553
|
AuthorityType["ManageList"] = "ManageList";
|
|
1505
1554
|
AuthorityType["UpdateMetadata"] = "UpdateMetadata";
|
|
1555
|
+
AuthorityType["Bridge"] = "Bridge";
|
|
1506
1556
|
})(AuthorityType || (AuthorityType = {}));
|
|
1507
1557
|
var AuthorityAction;
|
|
1508
1558
|
(function (AuthorityAction) {
|