@paymechain/sdk 1.0.4 → 1.0.7
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/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/models/index.d.ts +16 -36
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +7 -0
- package/dist/models/index.js.map +1 -1
- package/dist/payme-client.d.ts +0 -2
- package/dist/payme-client.d.ts.map +1 -1
- package/dist/payme-client.js +5 -6
- package/dist/payme-client.js.map +1 -1
- package/dist/services/index.d.ts +0 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +0 -1
- package/dist/services/index.js.map +1 -1
- package/dist/services/wallet.service.d.ts +13 -33
- package/dist/services/wallet.service.d.ts.map +1 -1
- package/dist/services/wallet.service.js +21 -37
- package/dist/services/wallet.service.js.map +1 -1
- package/dist/wallet/transaction-signer.d.ts +38 -0
- package/dist/wallet/transaction-signer.d.ts.map +1 -0
- package/dist/wallet/transaction-signer.js +153 -0
- package/dist/wallet/transaction-signer.js.map +1 -0
- package/package.json +6 -1
- package/dist/services/staking.service.d.ts +0 -25
- package/dist/services/staking.service.d.ts.map +0 -1
- package/dist/services/staking.service.js +0 -34
- package/dist/services/staking.service.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { PaymeClient } from './payme-client';
|
|
2
2
|
export type { PaymeClientConfig } from './payme-client';
|
|
3
|
+
export { TransactionSigner } from './wallet/transaction-signer';
|
|
4
|
+
export type { BuildSignedTransferArgs } from './wallet/transaction-signer';
|
|
3
5
|
export * from './models';
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,YAAY,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAG3E,cAAc,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -15,10 +15,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.PaymeClient = void 0;
|
|
18
|
+
exports.TransactionSigner = exports.PaymeClient = void 0;
|
|
19
19
|
// Main client entry point
|
|
20
20
|
var payme_client_1 = require("./payme-client");
|
|
21
21
|
Object.defineProperty(exports, "PaymeClient", { enumerable: true, get: function () { return payme_client_1.PaymeClient; } });
|
|
22
|
-
//
|
|
22
|
+
// PR-6: cripto local (mnemonic, derivação, assinatura).
|
|
23
|
+
var transaction_signer_1 = require("./wallet/transaction-signer");
|
|
24
|
+
Object.defineProperty(exports, "TransactionSigner", { enumerable: true, get: function () { return transaction_signer_1.TransactionSigner; } });
|
|
25
|
+
// Models públicos
|
|
23
26
|
__exportStar(require("./models"), exports);
|
|
24
27
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,eAAe;;;;;;;;;;;;;;;;;AAEf,0BAA0B;AAC1B,+CAA6C;AAApC,2GAAA,WAAW,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,eAAe;;;;;;;;;;;;;;;;;AAEf,0BAA0B;AAC1B,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AAGpB,wDAAwD;AACxD,kEAAgE;AAAvD,uHAAA,iBAAiB,OAAA;AAG1B,kBAAkB;AAClB,2CAAyB"}
|
package/dist/models/index.d.ts
CHANGED
|
@@ -14,12 +14,11 @@ export interface PagedResult<T> {
|
|
|
14
14
|
export interface AccountViewModel {
|
|
15
15
|
id: string;
|
|
16
16
|
address: string;
|
|
17
|
-
publicKey: string;
|
|
17
|
+
publicKey: string | null;
|
|
18
18
|
sequence: number;
|
|
19
19
|
}
|
|
20
20
|
export interface BalanceLineViewModel {
|
|
21
21
|
balance: number;
|
|
22
|
-
lockedBalance: number;
|
|
23
22
|
tokenId: string;
|
|
24
23
|
}
|
|
25
24
|
export interface RichListItemViewModel {
|
|
@@ -65,23 +64,6 @@ export interface NodeInfoModel {
|
|
|
65
64
|
url: string;
|
|
66
65
|
isValidator: boolean;
|
|
67
66
|
}
|
|
68
|
-
export interface UnbondingEntryViewModel {
|
|
69
|
-
validatorAddress: string;
|
|
70
|
-
amount: number;
|
|
71
|
-
releaseBlockHeight: number;
|
|
72
|
-
}
|
|
73
|
-
export interface StakeViewModel {
|
|
74
|
-
validatorAddress: string;
|
|
75
|
-
amount: number;
|
|
76
|
-
senderAddress: string;
|
|
77
|
-
signature: string;
|
|
78
|
-
}
|
|
79
|
-
export interface UnstakeViewModel {
|
|
80
|
-
validatorAddress: string;
|
|
81
|
-
amount: number;
|
|
82
|
-
senderAddress: string;
|
|
83
|
-
signature: string;
|
|
84
|
-
}
|
|
85
67
|
export interface NetworkStatisticsModel {
|
|
86
68
|
blockHeight: number;
|
|
87
69
|
totalTransactions: number;
|
|
@@ -99,13 +81,19 @@ export interface TokenViewModel {
|
|
|
99
81
|
export interface SubmitTransactionRequest {
|
|
100
82
|
accountAddress: string;
|
|
101
83
|
destinationAddress: string;
|
|
102
|
-
amount:
|
|
84
|
+
amount: string;
|
|
103
85
|
tokenId: string;
|
|
104
86
|
sequence: number;
|
|
105
87
|
baseFee: number;
|
|
106
88
|
priorityFee: number;
|
|
107
89
|
signature: string;
|
|
108
90
|
transactionHash: string;
|
|
91
|
+
/** PR-1: timestamp UTC ISO 8601 que entrou no hash (.NET 'o' format) */
|
|
92
|
+
timestamp: string;
|
|
93
|
+
/** PR-1 #19: byte do esquema. ECDSA = 0x00 (default). */
|
|
94
|
+
schemeId: number;
|
|
95
|
+
/** PR-1 #20: obrigatório na 1ª saída de um address. */
|
|
96
|
+
senderPublicKey: string;
|
|
109
97
|
}
|
|
110
98
|
export interface SubmitTransactionResponse {
|
|
111
99
|
transactionId: string;
|
|
@@ -127,23 +115,23 @@ export interface ValidatorModel {
|
|
|
127
115
|
publicKey: string;
|
|
128
116
|
isActive: boolean;
|
|
129
117
|
networkUrl?: string;
|
|
130
|
-
stakedAmount?: number;
|
|
131
118
|
uptime?: number;
|
|
132
119
|
}
|
|
133
|
-
export interface
|
|
120
|
+
export interface LocalWallet {
|
|
121
|
+
/** mnemonic BIP39 gerado localmente. NUNCA enviar para o gateway. */
|
|
134
122
|
mnemonic: string;
|
|
135
|
-
|
|
136
|
-
|
|
123
|
+
/** primeira conta derivada (m/44'/1000000'/0'/0/0). */
|
|
124
|
+
account: LocalDerivedAccount;
|
|
137
125
|
}
|
|
138
|
-
export interface
|
|
139
|
-
mnemonic: string;
|
|
140
|
-
publicKey: string;
|
|
126
|
+
export interface LocalDerivedAccount {
|
|
141
127
|
address: string;
|
|
128
|
+
publicKey: string;
|
|
129
|
+
/** índice usado em m/44'/1000000'/0'/0/{index} */
|
|
130
|
+
index: number;
|
|
142
131
|
}
|
|
143
132
|
export interface WalletAccountBalanceViewModel {
|
|
144
133
|
tokenId: string;
|
|
145
134
|
balance: number;
|
|
146
|
-
lockedBalance: number;
|
|
147
135
|
}
|
|
148
136
|
export interface WalletTransactionHistoryViewModel {
|
|
149
137
|
id: string;
|
|
@@ -154,12 +142,4 @@ export interface WalletTransactionHistoryViewModel {
|
|
|
154
142
|
tokenId: string;
|
|
155
143
|
timestamp: string;
|
|
156
144
|
}
|
|
157
|
-
export interface SendTransactionRequest {
|
|
158
|
-
mnemonic: string;
|
|
159
|
-
addressIndex: number;
|
|
160
|
-
fromAddress: string;
|
|
161
|
-
toAddress: string;
|
|
162
|
-
amount: number;
|
|
163
|
-
tokenId: string;
|
|
164
|
-
}
|
|
165
145
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,cAAc,CAAC,CAAC;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,WAAW,CAAC,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,CAAC,EAAE,CAAC;CACd;AAGD,MAAM,WAAW,gBAAgB;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,W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AE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,WAAW;IACxB,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,OAAO,EAAE,mBAAmB,CAAC;CAChC;AAED,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,6BAA6B;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iCAAiC;IAC9C,EAAE,EAAE,MAAM,CAAC;IACX,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACrB"}
|
package/dist/models/index.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// src/models/index.ts
|
|
3
|
+
//
|
|
4
|
+
// PR-1/PR-2/PR-6: shapes alinhados ao backend pós-refactor.
|
|
5
|
+
// - PR-1: SubmitTransactionRequest carrega schemeId + senderPublicKey + timestamp.
|
|
6
|
+
// - PR-1 #20: mnemonic NUNCA trafega via wire. Geração e derivação são locais
|
|
7
|
+
// (ver `wallet/transaction-signer`). LocalWallet/LocalDerivedAccount substituem
|
|
8
|
+
// CreateWalletViewModel/DeriveAddressViewModel.
|
|
9
|
+
// - PR-2: removidos LockedBalance, StakedAmount e todos os tipos de staking.
|
|
3
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
11
|
//# sourceMappingURL=index.js.map
|
package/dist/models/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";AAAA,sBAAsB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";AAAA,sBAAsB;AACtB,EAAE;AACF,4DAA4D;AAC5D,qFAAqF;AACrF,gFAAgF;AAChF,oFAAoF;AACpF,oDAAoD;AACpD,+EAA+E"}
|
package/dist/payme-client.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { AccountService } from './services/account.service';
|
|
|
3
3
|
import { BlockService } from './services/block.service';
|
|
4
4
|
import { ExplorerService } from './services/explorer.service';
|
|
5
5
|
import { LightClientService } from './services/light-client.service';
|
|
6
|
-
import { StakingService } from './services/staking.service';
|
|
7
6
|
import { StatisticsService } from './services/statistics.service';
|
|
8
7
|
import { TokenService } from './services/token.service';
|
|
9
8
|
import { TransactionService } from './services/transaction.service';
|
|
@@ -17,7 +16,6 @@ export declare class PaymeClient {
|
|
|
17
16
|
readonly block: BlockService;
|
|
18
17
|
readonly explorer: ExplorerService;
|
|
19
18
|
readonly lightClient: LightClientService;
|
|
20
|
-
readonly staking: StakingService;
|
|
21
19
|
readonly statistics: StatisticsService;
|
|
22
20
|
readonly token: TokenService;
|
|
23
21
|
readonly transaction: TransactionService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payme-client.d.ts","sourceRoot":"","sources":["../src/payme-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"payme-client.d.ts","sourceRoot":"","sources":["../src/payme-client.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGhE,MAAM,WAAW,iBAAiB;IAC9B,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,WAAW;IACpB,SAAgB,MAAM,EAAE,aAAa,CAAC;IACtC,SAAgB,OAAO,EAAE,cAAc,CAAC;IACxC,SAAgB,KAAK,EAAE,YAAY,CAAC;IACpC,SAAgB,QAAQ,EAAE,eAAe,CAAC;IAC1C,SAAgB,WAAW,EAAE,kBAAkB,CAAC;IAChD,SAAgB,UAAU,EAAE,iBAAiB,CAAC;IAC9C,SAAgB,KAAK,EAAE,YAAY,CAAC;IACpC,SAAgB,WAAW,EAAE,kBAAkB,CAAC;IAChD,SAAgB,SAAS,EAAE,gBAAgB,CAAC;gBAEhC,MAAM,EAAE,iBAAiB;CAiBxC"}
|
package/dist/payme-client.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// src/payme-client.ts
|
|
3
|
+
//
|
|
4
|
+
// PR-2: StakingService removido (rede é PoA, sem stake/unstake).
|
|
5
|
+
// PR-6: WalletService perdeu createWallet/deriveAddress/sendTransaction via REST.
|
|
6
|
+
// Use TransactionSigner.* (ou client.wallet.buildSignedTransfer + client.transaction.submitTransaction).
|
|
2
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
8
|
exports.PaymeClient = void 0;
|
|
4
|
-
// src/payme-client.ts
|
|
5
9
|
const wallet_service_1 = require("./services/wallet.service");
|
|
6
10
|
const account_service_1 = require("./services/account.service");
|
|
7
11
|
const block_service_1 = require("./services/block.service");
|
|
8
12
|
const explorer_service_1 = require("./services/explorer.service");
|
|
9
13
|
const light_client_service_1 = require("./services/light-client.service");
|
|
10
|
-
const staking_service_1 = require("./services/staking.service");
|
|
11
14
|
const statistics_service_1 = require("./services/statistics.service");
|
|
12
15
|
const token_service_1 = require("./services/token.service");
|
|
13
16
|
const transaction_service_1 = require("./services/transaction.service");
|
|
@@ -18,19 +21,15 @@ class PaymeClient {
|
|
|
18
21
|
if (!config.gatewayUrl) {
|
|
19
22
|
throw new Error("A configuração do PaymeClient deve fornecer 'gatewayUrl'.");
|
|
20
23
|
}
|
|
21
|
-
// Instantiate the base service for API calls, now using the gateway URL
|
|
22
24
|
const baseService = new base_service_1.BaseService(config.gatewayUrl);
|
|
23
|
-
// Instantiate all public-facing API services
|
|
24
25
|
this.wallet = new wallet_service_1.WalletService(baseService);
|
|
25
26
|
this.account = new account_service_1.AccountService(baseService);
|
|
26
27
|
this.block = new block_service_1.BlockService(baseService);
|
|
27
28
|
this.explorer = new explorer_service_1.ExplorerService(baseService);
|
|
28
29
|
this.lightClient = new light_client_service_1.LightClientService(baseService);
|
|
29
|
-
this.staking = new staking_service_1.StakingService(baseService);
|
|
30
30
|
this.statistics = new statistics_service_1.StatisticsService(baseService);
|
|
31
31
|
this.token = new token_service_1.TokenService(baseService);
|
|
32
32
|
this.transaction = new transaction_service_1.TransactionService(baseService);
|
|
33
|
-
// ValidatorService will now query gateway endpoints
|
|
34
33
|
this.validator = new validator_service_1.ValidatorService(baseService);
|
|
35
34
|
}
|
|
36
35
|
}
|
package/dist/payme-client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payme-client.js","sourceRoot":"","sources":["../src/payme-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"payme-client.js","sourceRoot":"","sources":["../src/payme-client.ts"],"names":[],"mappings":";AAAA,sBAAsB;AACtB,EAAE;AACF,iEAAiE;AACjE,kFAAkF;AAClF,+GAA+G;;;AAE/G,8DAA0D;AAC1D,gEAA4D;AAC5D,4DAAwD;AACxD,kEAA8D;AAC9D,0EAAqE;AACrE,sEAAkE;AAClE,4DAAwD;AACxD,wEAAoE;AACpE,oEAAgE;AAChE,0DAAsD;AAMtD,MAAa,WAAW;IAWpB,YAAY,MAAyB;QACjC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;QACjF,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,0BAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAEvD,IAAI,CAAC,MAAM,GAAG,IAAI,8BAAa,CAAC,WAAW,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,IAAI,gCAAc,CAAC,WAAW,CAAC,CAAC;QAC/C,IAAI,CAAC,KAAK,GAAG,IAAI,4BAAY,CAAC,WAAW,CAAC,CAAC;QAC3C,IAAI,CAAC,QAAQ,GAAG,IAAI,kCAAe,CAAC,WAAW,CAAC,CAAC;QACjD,IAAI,CAAC,WAAW,GAAG,IAAI,yCAAkB,CAAC,WAAW,CAAC,CAAC;QACvD,IAAI,CAAC,UAAU,GAAG,IAAI,sCAAiB,CAAC,WAAW,CAAC,CAAC;QACrD,IAAI,CAAC,KAAK,GAAG,IAAI,4BAAY,CAAC,WAAW,CAAC,CAAC;QAC3C,IAAI,CAAC,WAAW,GAAG,IAAI,wCAAkB,CAAC,WAAW,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,GAAG,IAAI,oCAAgB,CAAC,WAAW,CAAC,CAAC;IACvD,CAAC;CACJ;AA5BD,kCA4BC"}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export * from './base.service';
|
|
|
3
3
|
export * from './block.service';
|
|
4
4
|
export * from './explorer.service';
|
|
5
5
|
export * from './light-client.service';
|
|
6
|
-
export * from './staking.service';
|
|
7
6
|
export * from './statistics.service';
|
|
8
7
|
export * from './token.service';
|
|
9
8
|
export * from './transaction.service';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AACA,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AACA,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
|
package/dist/services/index.js
CHANGED
|
@@ -20,7 +20,6 @@ __exportStar(require("./base.service"), exports);
|
|
|
20
20
|
__exportStar(require("./block.service"), exports);
|
|
21
21
|
__exportStar(require("./explorer.service"), exports);
|
|
22
22
|
__exportStar(require("./light-client.service"), exports);
|
|
23
|
-
__exportStar(require("./staking.service"), exports);
|
|
24
23
|
__exportStar(require("./statistics.service"), exports);
|
|
25
24
|
__exportStar(require("./token.service"), exports);
|
|
26
25
|
__exportStar(require("./transaction.service"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wBAAwB;AACxB,oDAAkC;AAClC,iDAA+B;AAC/B,kDAAgC;AAChC,qDAAmC;AACnC,yDAAuC;AACvC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wBAAwB;AACxB,oDAAkC;AAClC,iDAA+B;AAC/B,kDAAgC;AAChC,qDAAmC;AACnC,yDAAuC;AACvC,uDAAqC;AACrC,kDAAgC;AAChC,wDAAsC;AACtC,sDAAoC;AACpC,mDAAiC"}
|
|
@@ -1,41 +1,21 @@
|
|
|
1
1
|
import { BaseService } from './base.service';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type { WalletAccountBalanceViewModel, WalletTransactionHistoryViewModel, LocalWallet, LocalDerivedAccount, SubmitTransactionRequest } from '../models';
|
|
3
|
+
import { BuildSignedTransferArgs } from '../wallet/transaction-signer';
|
|
4
|
+
/**
|
|
5
|
+
* PR-1 #20 / PR-6: mnemonic NUNCA é gerado nem trafegado pelo gateway. Tudo que envolve
|
|
6
|
+
* material criptográfico privado é puramente local (BIP39 + BIP44 + secp256k1 + Base58Check).
|
|
7
|
+
*
|
|
8
|
+
* REST passa a expor só leitura (balance, history). Para submeter tx, use
|
|
9
|
+
* `client.transaction.submitTransaction(TransactionSigner.buildSignedTransfer(...))`.
|
|
10
|
+
*/
|
|
5
11
|
export declare class WalletService {
|
|
6
12
|
private baseService;
|
|
7
13
|
constructor(baseService: BaseService);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
createWallet(): Promise<CreateWalletViewModel>;
|
|
13
|
-
/**
|
|
14
|
-
* Derives an address from a mnemonic phrase and index.
|
|
15
|
-
* @param mnemonic The mnemonic phrase.
|
|
16
|
-
* @param index The derivation index.
|
|
17
|
-
* @returns DeriveAddressViewModel
|
|
18
|
-
*/
|
|
19
|
-
deriveAddress(mnemonic: string, index: number): Promise<DeriveAddressViewModel>;
|
|
20
|
-
/**
|
|
21
|
-
* Gets the balance for a specific wallet address.
|
|
22
|
-
* @param address The wallet address.
|
|
23
|
-
* @returns Array of WalletAccountBalanceViewModel
|
|
24
|
-
*/
|
|
14
|
+
createWallet(): LocalWallet;
|
|
15
|
+
generateMnemonic(): string;
|
|
16
|
+
deriveAccount(mnemonic: string, index?: number): LocalDerivedAccount;
|
|
17
|
+
buildSignedTransfer(args: BuildSignedTransferArgs): SubmitTransactionRequest;
|
|
25
18
|
getWalletBalance(address: string): Promise<WalletAccountBalanceViewModel[]>;
|
|
26
|
-
/**
|
|
27
|
-
* Gets the transaction history for a specific wallet address and token ID.
|
|
28
|
-
* Note: This method is currently in AccountService in the .NET gateway, but logically belongs here.
|
|
29
|
-
* @param address The wallet address.
|
|
30
|
-
* @param tokenId The token identifier.
|
|
31
|
-
* @returns Array of WalletTransactionHistoryViewModel
|
|
32
|
-
*/
|
|
33
19
|
getWalletHistory(address: string, tokenId: string): Promise<WalletTransactionHistoryViewModel[]>;
|
|
34
|
-
/**
|
|
35
|
-
* Sends a transaction from the wallet.
|
|
36
|
-
* @param request The send transaction request object.
|
|
37
|
-
* @returns SubmitTransactionResponse
|
|
38
|
-
*/
|
|
39
|
-
sendTransaction(request: SendTransactionRequest): Promise<SubmitTransactionResponse>;
|
|
40
20
|
}
|
|
41
21
|
//# sourceMappingURL=wallet.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.service.d.ts","sourceRoot":"","sources":["../../src/services/wallet.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,
|
|
1
|
+
{"version":3,"file":"wallet.service.d.ts","sourceRoot":"","sources":["../../src/services/wallet.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EACR,6BAA6B,EAC7B,iCAAiC,EACjC,WAAW,EACX,mBAAmB,EACnB,wBAAwB,EAC3B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAqB,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAE1F;;;;;;GAMG;AACH,qBAAa,aAAa;IACV,OAAO,CAAC,WAAW;gBAAX,WAAW,EAAE,WAAW;IAI5C,YAAY,IAAI,WAAW;IAI3B,gBAAgB,IAAI,MAAM;IAI1B,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,mBAAmB;IAIvE,mBAAmB,CAAC,IAAI,EAAE,uBAAuB,GAAG,wBAAwB;IAMtE,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,6BAA6B,EAAE,CAAC;IAI3E,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,iCAAiC,EAAE,CAAC;CAIzG"}
|
|
@@ -1,53 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WalletService = void 0;
|
|
4
|
+
const transaction_signer_1 = require("../wallet/transaction-signer");
|
|
5
|
+
/**
|
|
6
|
+
* PR-1 #20 / PR-6: mnemonic NUNCA é gerado nem trafegado pelo gateway. Tudo que envolve
|
|
7
|
+
* material criptográfico privado é puramente local (BIP39 + BIP44 + secp256k1 + Base58Check).
|
|
8
|
+
*
|
|
9
|
+
* REST passa a expor só leitura (balance, history). Para submeter tx, use
|
|
10
|
+
* `client.transaction.submitTransaction(TransactionSigner.buildSignedTransfer(...))`.
|
|
11
|
+
*/
|
|
4
12
|
class WalletService {
|
|
5
13
|
constructor(baseService) {
|
|
6
14
|
this.baseService = baseService;
|
|
7
15
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
async createWallet() {
|
|
13
|
-
return this.baseService.post('/api/wallet/create');
|
|
16
|
+
// ---------- Operações puramente locais (nada vai para a rede) ----------
|
|
17
|
+
createWallet() {
|
|
18
|
+
return transaction_signer_1.TransactionSigner.createWallet();
|
|
14
19
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* @param mnemonic The mnemonic phrase.
|
|
18
|
-
* @param index The derivation index.
|
|
19
|
-
* @returns DeriveAddressViewModel
|
|
20
|
-
*/
|
|
21
|
-
async deriveAddress(mnemonic, index) {
|
|
22
|
-
const params = { mnemonic, index };
|
|
23
|
-
return this.baseService.get('/api/wallet/derive-address', params);
|
|
20
|
+
generateMnemonic() {
|
|
21
|
+
return transaction_signer_1.TransactionSigner.generateMnemonic();
|
|
24
22
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
deriveAccount(mnemonic, index = 0) {
|
|
24
|
+
return transaction_signer_1.TransactionSigner.deriveAccount(mnemonic, index);
|
|
25
|
+
}
|
|
26
|
+
buildSignedTransfer(args) {
|
|
27
|
+
return transaction_signer_1.TransactionSigner.buildSignedTransfer(args);
|
|
28
|
+
}
|
|
29
|
+
// ---------- Operações read-only (REST do gateway) ----------
|
|
30
30
|
async getWalletBalance(address) {
|
|
31
31
|
return this.baseService.get(`/api/wallet/${address}/balance`);
|
|
32
32
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Gets the transaction history for a specific wallet address and token ID.
|
|
35
|
-
* Note: This method is currently in AccountService in the .NET gateway, but logically belongs here.
|
|
36
|
-
* @param address The wallet address.
|
|
37
|
-
* @param tokenId The token identifier.
|
|
38
|
-
* @returns Array of WalletTransactionHistoryViewModel
|
|
39
|
-
*/
|
|
40
33
|
async getWalletHistory(address, tokenId) {
|
|
41
|
-
|
|
42
|
-
return this.baseService.get(`/api/wallet/${address}/history/${tokenId}`, params);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Sends a transaction from the wallet.
|
|
46
|
-
* @param request The send transaction request object.
|
|
47
|
-
* @returns SubmitTransactionResponse
|
|
48
|
-
*/
|
|
49
|
-
async sendTransaction(request) {
|
|
50
|
-
return this.baseService.post('/api/wallet/send-transaction', request);
|
|
34
|
+
return this.baseService.get(`/api/wallet/${address}/history/${tokenId}`);
|
|
51
35
|
}
|
|
52
36
|
}
|
|
53
37
|
exports.WalletService = WalletService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.service.js","sourceRoot":"","sources":["../../src/services/wallet.service.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"wallet.service.js","sourceRoot":"","sources":["../../src/services/wallet.service.ts"],"names":[],"mappings":";;;AAQA,qEAA0F;AAE1F;;;;;;GAMG;AACH,MAAa,aAAa;IACtB,YAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAEhD,0EAA0E;IAE1E,YAAY;QACR,OAAO,sCAAiB,CAAC,YAAY,EAAE,CAAC;IAC5C,CAAC;IAED,gBAAgB;QACZ,OAAO,sCAAiB,CAAC,gBAAgB,EAAE,CAAC;IAChD,CAAC;IAED,aAAa,CAAC,QAAgB,EAAE,QAAgB,CAAC;QAC7C,OAAO,sCAAiB,CAAC,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC5D,CAAC;IAED,mBAAmB,CAAC,IAA6B;QAC7C,OAAO,sCAAiB,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IAED,8DAA8D;IAE9D,KAAK,CAAC,gBAAgB,CAAC,OAAe;QAClC,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAkC,eAAe,OAAO,UAAU,CAAC,CAAC;IACnG,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,OAAe,EAAE,OAAe;QACnD,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CACvB,eAAe,OAAO,YAAY,OAAO,EAAE,CAAC,CAAC;IACrD,CAAC;CACJ;AA/BD,sCA+BC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { LocalDerivedAccount, LocalWallet, SubmitTransactionRequest } from '../models';
|
|
2
|
+
export interface BuildSignedTransferArgs {
|
|
3
|
+
/** mnemonic BIP39 do sender (NUNCA é enviado para o gateway) */
|
|
4
|
+
mnemonic: string;
|
|
5
|
+
/** índice em m/44'/1000000'/0'/0/{addressIndex}. Default = 0. */
|
|
6
|
+
addressIndex?: number;
|
|
7
|
+
destinationAddress: string;
|
|
8
|
+
tokenId: string;
|
|
9
|
+
/** amount em PicoPayme. Aceita bigint ou string decimal sem ponto. */
|
|
10
|
+
amount: bigint | string;
|
|
11
|
+
/** sequence: senderAccount.sequence + 1 (ou 1 se conta nova). */
|
|
12
|
+
sequence: number;
|
|
13
|
+
baseFee: bigint | string;
|
|
14
|
+
priorityFee: bigint | string;
|
|
15
|
+
/** Se ausente, usa Date.now() em UTC. */
|
|
16
|
+
timestamp?: Date;
|
|
17
|
+
}
|
|
18
|
+
export declare class TransactionSigner {
|
|
19
|
+
static readonly SCHEME_ECDSA: number;
|
|
20
|
+
/** Gera mnemonic 12-words. Função pura: nada vai pra rede. */
|
|
21
|
+
static generateMnemonic(): string;
|
|
22
|
+
/** Cria uma carteira (mnemonic + conta índice 0). */
|
|
23
|
+
static createWallet(): LocalWallet;
|
|
24
|
+
/** Deriva conta no índice especificado (path BIP44). */
|
|
25
|
+
static deriveAccount(mnemonic: string, index?: number): LocalDerivedAccount;
|
|
26
|
+
/** Address = Base58Check(0x00 || RIPEMD160(SHA256(pubkey compressed))). */
|
|
27
|
+
static deriveAddress(publicKeyCompressed: Uint8Array): string;
|
|
28
|
+
/**
|
|
29
|
+
* Monta uma Tx Transfer e devolve a forma pronta pra POST /api/transaction.
|
|
30
|
+
* Não envia — só prepara. O caller usa `client.transaction.submitTransaction(...)`.
|
|
31
|
+
*/
|
|
32
|
+
static buildSignedTransfer(args: BuildSignedTransferArgs): SubmitTransactionRequest;
|
|
33
|
+
private static derivePrivateKey;
|
|
34
|
+
/** Helper público — útil para testes ou ferramentas. */
|
|
35
|
+
static toHex(bytes: Uint8Array): string;
|
|
36
|
+
static fromHex(hex: string): Uint8Array;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=transaction-signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-signer.d.ts","sourceRoot":"","sources":["../../src/wallet/transaction-signer.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,wBAAwB,E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) TransactionSigner e
|
|
5
|
+
// DE.Payme.Core.Crypto.EcdsaSecp256k1Scheme.
|
|
6
|
+
//
|
|
7
|
+
// - Mnemonic BIP39 (12 palavras).
|
|
8
|
+
// - HD path BIP44: m/44'/1000000'/0'/0/{index}.
|
|
9
|
+
// - Pubkey compressed secp256k1 (33 bytes).
|
|
10
|
+
// - Address: Base58Check(0x00 || RIPEMD160(SHA256(pubkey))).
|
|
11
|
+
// - Hash da Tx: SHA256(UTF-8 do "schemeId|type|account|dest|tokenId|amount|seq|baseFee|priorityFee|tsO"),
|
|
12
|
+
// onde tsO é o timestamp UTC em formato "yyyy-MM-ddTHH:mm:ss.fffffffZ" (idem .NET 'o').
|
|
13
|
+
// - Assinatura: ECDSA compact recoverable, wire = [recId+27, 64 bytes].
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.TransactionSigner = void 0;
|
|
16
|
+
const bip39_1 = require("@scure/bip39");
|
|
17
|
+
const english_js_1 = require("@scure/bip39/wordlists/english.js");
|
|
18
|
+
const bip32_1 = require("@scure/bip32");
|
|
19
|
+
const secp256k1_js_1 = require("@noble/curves/secp256k1.js");
|
|
20
|
+
const sha2_js_1 = require("@noble/hashes/sha2.js");
|
|
21
|
+
const legacy_js_1 = require("@noble/hashes/legacy.js");
|
|
22
|
+
const base_1 = require("@scure/base");
|
|
23
|
+
const SCHEME_ECDSA = 0x00;
|
|
24
|
+
const TX_TYPE_TRANSFER = 0;
|
|
25
|
+
const bs58c = (0, base_1.base58check)(sha2_js_1.sha256);
|
|
26
|
+
function toHex(bytes) {
|
|
27
|
+
let out = '';
|
|
28
|
+
for (const b of bytes)
|
|
29
|
+
out += b.toString(16).padStart(2, '0');
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
function fromHex(hex) {
|
|
33
|
+
const clean = hex.startsWith('0x') ? hex.slice(2) : hex;
|
|
34
|
+
if (clean.length % 2 !== 0)
|
|
35
|
+
throw new Error('hex string must have even length');
|
|
36
|
+
const out = new Uint8Array(clean.length / 2);
|
|
37
|
+
for (let i = 0; i < out.length; i++) {
|
|
38
|
+
out[i] = parseInt(clean.substr(i * 2, 2), 16);
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Formata uma Date UTC no padrão .NET "o": "yyyy-MM-ddTHH:mm:ss.fffffffZ".
|
|
44
|
+
* JS Date só tem precisão de milissegundo (3 dígitos); padding com 4 zeros à direita.
|
|
45
|
+
* O server reconstrói a tx com a mesma timestamp e recomputa o hash; precisa bater
|
|
46
|
+
* caractere a caractere.
|
|
47
|
+
*/
|
|
48
|
+
function formatDotnetUtcO(d) {
|
|
49
|
+
const pad = (n, len = 2) => String(n).padStart(len, '0');
|
|
50
|
+
const yyyy = d.getUTCFullYear();
|
|
51
|
+
const MM = pad(d.getUTCMonth() + 1);
|
|
52
|
+
const dd = pad(d.getUTCDate());
|
|
53
|
+
const HH = pad(d.getUTCHours());
|
|
54
|
+
const mm = pad(d.getUTCMinutes());
|
|
55
|
+
const ss = pad(d.getUTCSeconds());
|
|
56
|
+
const ms = pad(d.getUTCMilliseconds(), 3);
|
|
57
|
+
return `${yyyy}-${MM}-${dd}T${HH}:${mm}:${ss}.${ms}0000Z`;
|
|
58
|
+
}
|
|
59
|
+
class TransactionSigner {
|
|
60
|
+
/** Gera mnemonic 12-words. Função pura: nada vai pra rede. */
|
|
61
|
+
static generateMnemonic() {
|
|
62
|
+
return (0, bip39_1.generateMnemonic)(english_js_1.wordlist, 128);
|
|
63
|
+
}
|
|
64
|
+
/** Cria uma carteira (mnemonic + conta índice 0). */
|
|
65
|
+
static createWallet() {
|
|
66
|
+
const mnemonic = TransactionSigner.generateMnemonic();
|
|
67
|
+
const account = TransactionSigner.deriveAccount(mnemonic, 0);
|
|
68
|
+
return { mnemonic, account };
|
|
69
|
+
}
|
|
70
|
+
/** Deriva conta no índice especificado (path BIP44). */
|
|
71
|
+
static deriveAccount(mnemonic, index = 0) {
|
|
72
|
+
const { publicKey } = TransactionSigner.derivePrivateKey(mnemonic, index);
|
|
73
|
+
return {
|
|
74
|
+
address: TransactionSigner.deriveAddress(publicKey),
|
|
75
|
+
publicKey: toHex(publicKey),
|
|
76
|
+
index,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** Address = Base58Check(0x00 || RIPEMD160(SHA256(pubkey compressed))). */
|
|
80
|
+
static deriveAddress(publicKeyCompressed) {
|
|
81
|
+
if (publicKeyCompressed.length !== 33) {
|
|
82
|
+
throw new Error(`expected 33-byte compressed pubkey, got ${publicKeyCompressed.length}`);
|
|
83
|
+
}
|
|
84
|
+
const sha = (0, sha2_js_1.sha256)(publicKeyCompressed);
|
|
85
|
+
const h160 = (0, legacy_js_1.ripemd160)(sha);
|
|
86
|
+
const payload = new Uint8Array(21);
|
|
87
|
+
payload[0] = SCHEME_ECDSA;
|
|
88
|
+
payload.set(h160, 1);
|
|
89
|
+
return bs58c.encode(payload);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Monta uma Tx Transfer e devolve a forma pronta pra POST /api/transaction.
|
|
93
|
+
* Não envia — só prepara. O caller usa `client.transaction.submitTransaction(...)`.
|
|
94
|
+
*/
|
|
95
|
+
static buildSignedTransfer(args) {
|
|
96
|
+
const { privateKey, publicKey } = TransactionSigner.derivePrivateKey(args.mnemonic, args.addressIndex ?? 0);
|
|
97
|
+
const accountAddress = TransactionSigner.deriveAddress(publicKey);
|
|
98
|
+
const ts = args.timestamp ?? new Date();
|
|
99
|
+
const tsO = formatDotnetUtcO(ts);
|
|
100
|
+
const amount = String(args.amount);
|
|
101
|
+
const baseFee = String(args.baseFee);
|
|
102
|
+
const priorityFee = String(args.priorityFee);
|
|
103
|
+
const hashInput = `${SCHEME_ECDSA.toString(16).padStart(2, '0').toUpperCase()}|` +
|
|
104
|
+
`${TX_TYPE_TRANSFER}|` +
|
|
105
|
+
`${accountAddress}|` +
|
|
106
|
+
`${args.destinationAddress}|` +
|
|
107
|
+
`${args.tokenId}|` +
|
|
108
|
+
`${amount}|` +
|
|
109
|
+
`${args.sequence}|` +
|
|
110
|
+
`${baseFee}|` +
|
|
111
|
+
`${priorityFee}|` +
|
|
112
|
+
`${tsO}`;
|
|
113
|
+
const hashBytes = (0, sha2_js_1.sha256)(new TextEncoder().encode(hashInput));
|
|
114
|
+
const transactionHash = toHex(hashBytes);
|
|
115
|
+
// @noble/curves 2.x: format 'recovered' devolve [recId(1), r(32), s(32)] = 65 bytes.
|
|
116
|
+
// .NET espera wire = [recId+27, compact(64)]. Reagrupamos aqui.
|
|
117
|
+
const sigBytes = secp256k1_js_1.secp256k1.sign(hashBytes, privateKey, { format: 'recovered', prehash: false });
|
|
118
|
+
const recovery = sigBytes[0];
|
|
119
|
+
const wire = new Uint8Array(65);
|
|
120
|
+
wire[0] = 27 + recovery;
|
|
121
|
+
wire.set(sigBytes.subarray(1, 65), 1);
|
|
122
|
+
const signature = toHex(wire);
|
|
123
|
+
return {
|
|
124
|
+
accountAddress,
|
|
125
|
+
destinationAddress: args.destinationAddress,
|
|
126
|
+
tokenId: args.tokenId,
|
|
127
|
+
amount,
|
|
128
|
+
sequence: args.sequence,
|
|
129
|
+
baseFee: Number(baseFee),
|
|
130
|
+
priorityFee: Number(priorityFee),
|
|
131
|
+
signature,
|
|
132
|
+
transactionHash,
|
|
133
|
+
timestamp: tsO,
|
|
134
|
+
schemeId: SCHEME_ECDSA,
|
|
135
|
+
senderPublicKey: toHex(publicKey),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
static derivePrivateKey(mnemonic, index) {
|
|
139
|
+
const seed = (0, bip39_1.mnemonicToSeedSync)(mnemonic);
|
|
140
|
+
const root = bip32_1.HDKey.fromMasterSeed(seed);
|
|
141
|
+
const child = root.derive(`m/44'/1000000'/0'/0/${index}`);
|
|
142
|
+
if (!child.privateKey)
|
|
143
|
+
throw new Error('HD derivation did not produce a private key');
|
|
144
|
+
const pub = secp256k1_js_1.secp256k1.getPublicKey(child.privateKey, /* compressed */ true);
|
|
145
|
+
return { privateKey: child.privateKey, publicKey: pub };
|
|
146
|
+
}
|
|
147
|
+
/** Helper público — útil para testes ou ferramentas. */
|
|
148
|
+
static toHex(bytes) { return toHex(bytes); }
|
|
149
|
+
static fromHex(hex) { return fromHex(hex); }
|
|
150
|
+
}
|
|
151
|
+
exports.TransactionSigner = TransactionSigner;
|
|
152
|
+
TransactionSigner.SCHEME_ECDSA = SCHEME_ECDSA;
|
|
153
|
+
//# sourceMappingURL=transaction-signer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-signer.js","sourceRoot":"","sources":["../../src/wallet/transaction-signer.ts"],"names":[],"mappings":";AAAA,mCAAmC;AACnC,EAAE;AACF,qFAAqF;AACrF,6CAA6C;AAC7C,EAAE;AACF,oCAAoC;AACpC,kDAAkD;AAClD,8CAA8C;AAC9C,+DAA+D;AAC/D,4GAA4G;AAC5G,4FAA4F;AAC5F,0EAA0E;;;AAE1E,wCAAqF;AACrF,kEAA6D;AAC7D,wCAAqC;AACrC,6DAAuD;AACvD,mDAA+C;AAC/C,uDAAoD;AACpD,sCAA0C;AAG1C,MAAM,YAAY,GAAW,IAAI,CAAC;AAClC,MAAM,gBAAgB,GAAW,CAAC,CAAC;AAEnC,MAAM,KAAK,GAAG,IAAA,kBAAW,EAAC,gBAAM,CAAC,CAAC;AAElC,SAAS,KAAK,CAAC,KAAiB;IAC5B,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,GAAG,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC9D,OAAO,GAAG,CAAC;AACf,CAAC;AAED,SAAS,OAAO,CAAC,GAAW;IACxB,MAAM,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CA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,CAAC,KAAK,CAAC,UAAU;YAAE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACtF,MAAM,GAAG,GAAG,wBAAS,CAAC,YAAY,CAAC,KAAK,CAAC,UAAU,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC5E,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;IAC5D,CAAC;IAED,wDAAwD;IACxD,MAAM,CAAC,KAAK,CAAC,KAAiB,IAAY,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChE,MAAM,CAAC,OAAO,CAAC,GAAW,IAAgB,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;;AA1GpE,8CA2GC;AA1GmB,8BAAY,GAAG,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paymechain/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Official TypeScript SDK for the PaymeChain blockchain. Provides a resilient, framework-agnostic client for interacting with network nodes, managing accounts, submitting transactions, and subscribing to real-time events.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -35,6 +35,11 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
+
"@noble/curves": "^2.2.0",
|
|
39
|
+
"@noble/hashes": "^2.2.0",
|
|
40
|
+
"@scure/base": "^2.2.0",
|
|
41
|
+
"@scure/bip32": "^2.2.0",
|
|
42
|
+
"@scure/bip39": "^2.2.0",
|
|
38
43
|
"axios": "^1.6.2"
|
|
39
44
|
},
|
|
40
45
|
"devDependencies": {
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { BaseService } from './base.service';
|
|
2
|
-
import { UnbondingEntryViewModel, StakeViewModel, UnstakeViewModel } from '../models';
|
|
3
|
-
export declare class StakingService {
|
|
4
|
-
private baseService;
|
|
5
|
-
constructor(baseService: BaseService);
|
|
6
|
-
/**
|
|
7
|
-
* Gets a list of delegations for a specific address.
|
|
8
|
-
* @param address The address to query delegations for.
|
|
9
|
-
* @returns Array of UnbondingEntryViewModel
|
|
10
|
-
*/
|
|
11
|
-
getDelegations(address: string): Promise<UnbondingEntryViewModel[]>;
|
|
12
|
-
/**
|
|
13
|
-
* Submits a staking transaction.
|
|
14
|
-
* @param model The staking details.
|
|
15
|
-
* @returns object (assuming the gateway returns a generic object for success)
|
|
16
|
-
*/
|
|
17
|
-
stake(model: StakeViewModel): Promise<object>;
|
|
18
|
-
/**
|
|
19
|
-
* Submits an unstaking transaction.
|
|
20
|
-
* @param model The unstaking details.
|
|
21
|
-
* @returns object (assuming the gateway returns a generic object for success)
|
|
22
|
-
*/
|
|
23
|
-
unstake(model: UnstakeViewModel): Promise<object>;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=staking.service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"staking.service.d.ts","sourceRoot":"","sources":["../../src/services/staking.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAEtF,qBAAa,cAAc;IACb,OAAO,CAAC,WAAW;gBAAX,WAAW,EAAE,WAAW;IAE5C;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,EAAE,CAAC;IAIzE;;;;OAIG;IACG,KAAK,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAInD;;;;OAIG;IACG,OAAO,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;CAGxD"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StakingService = void 0;
|
|
4
|
-
class StakingService {
|
|
5
|
-
constructor(baseService) {
|
|
6
|
-
this.baseService = baseService;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Gets a list of delegations for a specific address.
|
|
10
|
-
* @param address The address to query delegations for.
|
|
11
|
-
* @returns Array of UnbondingEntryViewModel
|
|
12
|
-
*/
|
|
13
|
-
async getDelegations(address) {
|
|
14
|
-
return this.baseService.get(`/api/staking/${address}/delegations`);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Submits a staking transaction.
|
|
18
|
-
* @param model The staking details.
|
|
19
|
-
* @returns object (assuming the gateway returns a generic object for success)
|
|
20
|
-
*/
|
|
21
|
-
async stake(model) {
|
|
22
|
-
return this.baseService.post('/api/staking/stake', model);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Submits an unstaking transaction.
|
|
26
|
-
* @param model The unstaking details.
|
|
27
|
-
* @returns object (assuming the gateway returns a generic object for success)
|
|
28
|
-
*/
|
|
29
|
-
async unstake(model) {
|
|
30
|
-
return this.baseService.post('/api/staking/unstake', model);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.StakingService = StakingService;
|
|
34
|
-
//# sourceMappingURL=staking.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"staking.service.js","sourceRoot":"","sources":["../../src/services/staking.service.ts"],"names":[],"mappings":";;;AAGA,MAAa,cAAc;IACzB,YAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAEhD;;;;OAIG;IACH,KAAK,CAAC,cAAc,CAAC,OAAe;QAClC,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAA4B,gBAAgB,OAAO,cAAc,CAAC,CAAC;IAChG,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,KAAK,CAAC,KAAqB;QAC/B,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAS,oBAAoB,EAAE,KAAK,CAAC,CAAC;IACpE,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,KAAuB;QACnC,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAS,sBAAsB,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;CACF;AA7BD,wCA6BC"}
|