@guveno/wallet-sdk 1.0.2 → 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/README.md +88 -124
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +5 -1
- package/dist/api/client.js.map +1 -1
- package/dist/api/types.d.ts +10 -1
- package/dist/api/types.d.ts.map +1 -1
- package/dist/encryption-session.d.ts +7 -0
- package/dist/encryption-session.d.ts.map +1 -1
- package/dist/encryption-session.js +8 -1
- package/dist/encryption-session.js.map +1 -1
- package/dist/guveno.d.ts +83 -0
- package/dist/guveno.d.ts.map +1 -0
- package/dist/guveno.js +116 -0
- package/dist/guveno.js.map +1 -0
- package/dist/hot-wallet.d.ts +25 -7
- package/dist/hot-wallet.d.ts.map +1 -1
- package/dist/hot-wallet.js +36 -19
- package/dist/hot-wallet.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/signing/sign-bitcoin.d.ts +8 -7
- package/dist/signing/sign-bitcoin.d.ts.map +1 -1
- package/dist/signing/sign-bitcoin.js +39 -31
- package/dist/signing/sign-bitcoin.js.map +1 -1
- package/dist/signing/sign-withdrawal.d.ts +3 -1
- package/dist/signing/sign-withdrawal.d.ts.map +1 -1
- package/dist/signing/sign-withdrawal.js +5 -2
- package/dist/signing/sign-withdrawal.js.map +1 -1
- package/dist/signing/types.d.ts +8 -0
- package/dist/signing/types.d.ts.map +1 -1
- package/dist/signing/types.js.map +1 -1
- package/dist/wallet.d.ts +63 -0
- package/dist/wallet.d.ts.map +1 -0
- package/dist/wallet.js +84 -0
- package/dist/wallet.js.map +1 -0
- package/package.json +2 -2
|
@@ -8,13 +8,15 @@ export interface SignWithdrawalInput {
|
|
|
8
8
|
derivationPath: string;
|
|
9
9
|
/** Caller-customized Ethereum gas (wei / units); falls back to server suggestions. */
|
|
10
10
|
ethereumGas?: EthereumGasOverrides;
|
|
11
|
+
/** Caller-customized Bitcoin fee rate (sat/vB); falls back to the server suggestion. */
|
|
12
|
+
bitcoinFeeRate?: number;
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
15
|
* Produces a fully-signed raw transaction (hex) for a prepared withdrawal. Pure — no
|
|
14
16
|
* network access. New chains are added here as their per-chain signer + server chain
|
|
15
17
|
* state land.
|
|
16
18
|
*/
|
|
17
|
-
export declare function signWithdrawal({ payload, mnemonic, derivationPath, ethereumGas }: SignWithdrawalInput): Promise<string>;
|
|
19
|
+
export declare function signWithdrawal({ payload, mnemonic, derivationPath, ethereumGas, bitcoinFeeRate }: SignWithdrawalInput): Promise<string>;
|
|
18
20
|
/** Chains the SDK signer currently supports. */
|
|
19
21
|
export declare const SIGNABLE_CHAINS: readonly ["ethereum", "xrp", "bitcoin", "polkadot"];
|
|
20
22
|
export declare function canSignChain(chain: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sign-withdrawal.d.ts","sourceRoot":"","sources":["../../src/signing/sign-withdrawal.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAGvF,OAAO,EAAmD,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAElG,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,cAAc,CAAC;IACxB,2FAA2F;IAC3F,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,cAAc,EAAE,MAAM,CAAC;IACvB,sFAAsF;IACtF,WAAW,CAAC,EAAE,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"sign-withdrawal.d.ts","sourceRoot":"","sources":["../../src/signing/sign-withdrawal.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAGvF,OAAO,EAAmD,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAElG,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,cAAc,CAAC;IACxB,2FAA2F;IAC3F,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,cAAc,EAAE,MAAM,CAAC;IACvB,sFAAsF;IACtF,WAAW,CAAC,EAAE,oBAAoB,CAAC;IACnC,wFAAwF;IACxF,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,EACnC,OAAO,EACP,QAAQ,EACR,cAAc,EACd,WAAW,EACX,cAAc,EACf,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAsBvC;AAED,gDAAgD;AAChD,eAAO,MAAM,eAAe,qDAAsD,CAAC;AAEnF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEnD"}
|
|
@@ -9,7 +9,7 @@ import { UnsupportedSigningError, WithdrawalExpiredError } from './types.js';
|
|
|
9
9
|
* network access. New chains are added here as their per-chain signer + server chain
|
|
10
10
|
* state land.
|
|
11
11
|
*/
|
|
12
|
-
export async function signWithdrawal({ payload, mnemonic, derivationPath, ethereumGas }) {
|
|
12
|
+
export async function signWithdrawal({ payload, mnemonic, derivationPath, ethereumGas, bitcoinFeeRate }) {
|
|
13
13
|
assertValidMnemonic(mnemonic);
|
|
14
14
|
if (Date.now() >= new Date(payload.expiresAt).getTime()) {
|
|
15
15
|
throw new WithdrawalExpiredError();
|
|
@@ -20,7 +20,10 @@ export async function signWithdrawal({ payload, mnemonic, derivationPath, ethere
|
|
|
20
20
|
case 'xrp':
|
|
21
21
|
return signXrpWithdrawal(payload, mnemonic, derivationPath);
|
|
22
22
|
case 'bitcoin':
|
|
23
|
-
|
|
23
|
+
// Bitcoin derives a key per input from each UTXO's own path (in chainState),
|
|
24
|
+
// so the address-level derivationPath isn't used here. An optional fee-rate
|
|
25
|
+
// override (sat/vB) replaces the server's suggestion.
|
|
26
|
+
return signBitcoinWithdrawal(payload, mnemonic, bitcoinFeeRate);
|
|
24
27
|
case 'polkadot':
|
|
25
28
|
return signPolkadotWithdrawal(payload, mnemonic, derivationPath);
|
|
26
29
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sign-withdrawal.js","sourceRoot":"","sources":["../../src/signing/sign-withdrawal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAA6B,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAuB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"sign-withdrawal.js","sourceRoot":"","sources":["../../src/signing/sign-withdrawal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAA6B,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAuB,MAAM,YAAY,CAAC;AAclG;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EACnC,OAAO,EACP,QAAQ,EACR,cAAc,EACd,WAAW,EACX,cAAc,EACM;IACpB,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAE9B,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;QACxD,MAAM,IAAI,sBAAsB,EAAE,CAAC;IACrC,CAAC;IAED,QAAQ,OAAO,CAAC,KAAK,EAAE,CAAC;QACtB,KAAK,UAAU;YACb,OAAO,sBAAsB,CAAC,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,CAAC,CAAC;QAChF,KAAK,KAAK;YACR,OAAO,iBAAiB,CAAC,OAAO,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;QAC9D,KAAK,SAAS;YACZ,6EAA6E;YAC7E,4EAA4E;YAC5E,sDAAsD;YACtD,OAAO,qBAAqB,CAAC,OAAO,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;QAClE,KAAK,UAAU;YACb,OAAO,sBAAsB,CAAC,OAAO,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;QACnE;YACE,MAAM,IAAI,uBAAuB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACrD,CAAC;AACH,CAAC;AAED,gDAAgD;AAChD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAU,CAAC;AAEnF,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAQ,eAAqC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
|
package/dist/signing/types.d.ts
CHANGED
|
@@ -16,13 +16,21 @@ export interface EthereumChainState {
|
|
|
16
16
|
gasLimit: string;
|
|
17
17
|
}
|
|
18
18
|
export interface BitcoinChainState {
|
|
19
|
+
/**
|
|
20
|
+
* The exact inputs the server coin-selected (already covering amount + fee).
|
|
21
|
+
* Each carries its owning address + derivation path so an aggregated tx can
|
|
22
|
+
* sign every input with the right key.
|
|
23
|
+
*/
|
|
19
24
|
utxos: Array<{
|
|
20
25
|
txid: string;
|
|
21
26
|
vout: number;
|
|
22
27
|
value: number;
|
|
28
|
+
address: string;
|
|
29
|
+
derivationPath: string;
|
|
23
30
|
scriptPubKey?: string;
|
|
24
31
|
}>;
|
|
25
32
|
feeRate: number;
|
|
33
|
+
/** Wallet-owned address that any change output returns to. */
|
|
26
34
|
changeAddress: string;
|
|
27
35
|
}
|
|
28
36
|
export interface XrpChainState {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/signing/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpE,wGAAwG;AACxG,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/signing/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpE,wGAAwG;AACxG,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ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,aAAa,GAAG,kBAAkB,CAAC;AAErG,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,cAAc,CAAC;IACtB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,uFAAuF;IACvF,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,YAAY,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,gFAAgF;AAChF,qBAAa,sBAAuB,SAAQ,KAAK;;CAKhD;AAED,iEAAiE;AACjE,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,KAAK,EAAE,MAAM;CAI1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/signing/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/signing/types.ts"],"names":[],"mappings":"AAqFA,gFAAgF;AAChF,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C;QACE,KAAK,CAAC,kEAAkE,CAAC,CAAC;QAC1E,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED,iEAAiE;AACjE,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YAAY,KAAa;QACvB,KAAK,CAAC,cAAc,KAAK,wBAAwB,CAAC,CAAC;QACnD,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF"}
|
package/dist/wallet.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { GuvenoApiClient } from './api/client.js';
|
|
2
|
+
import type { ApiPageInfo, ApiWalletAddress, ApiWalletDetail, ListApiAddressOptions } from './api/types.js';
|
|
3
|
+
import type { ApiChain, ApiNetwork, ApiWithdrawal } from './api/types.js';
|
|
4
|
+
import type { EncryptionSession } from './encryption-session.js';
|
|
5
|
+
import { type WithdrawInput } from './hot-wallet.js';
|
|
6
|
+
import type { KeyProvider } from './keyprovider/index.js';
|
|
7
|
+
import { type DeriveAddressOptions, type DeriveAddressResult } from './wallet-service.js';
|
|
8
|
+
/**
|
|
9
|
+
* A withdrawal request from a loaded wallet. The wallet is implied, so `walletId`
|
|
10
|
+
* is omitted — pass the source `addressId` and the asset/amount/destination.
|
|
11
|
+
*/
|
|
12
|
+
export type WalletWithdrawInput = Omit<WithdrawInput, 'walletId'>;
|
|
13
|
+
export interface WalletDeps {
|
|
14
|
+
api: GuvenoApiClient;
|
|
15
|
+
detail: ApiWalletDetail;
|
|
16
|
+
/** Server-source-of-truth mode: unlocked with the user's encryption password. */
|
|
17
|
+
session?: EncryptionSession;
|
|
18
|
+
/** Headless mode: the recovery phrase is sourced from a KMS/HSM/file provider. */
|
|
19
|
+
keys?: KeyProvider;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A single wallet, ready to use. Returned by {@link Guveno.loadWallet},
|
|
23
|
+
* {@link Guveno.createWallet}, and {@link Guveno.importWallet}. The signing key
|
|
24
|
+
* is already resolved (either the unlocked encryption key, or a key provider), so
|
|
25
|
+
* you can withdraw, derive addresses, and reveal the recovery phrase without
|
|
26
|
+
* re-supplying credentials.
|
|
27
|
+
*/
|
|
28
|
+
export declare class Wallet {
|
|
29
|
+
private readonly api;
|
|
30
|
+
private readonly session;
|
|
31
|
+
private readonly hot;
|
|
32
|
+
private readonly service;
|
|
33
|
+
private walletDetail;
|
|
34
|
+
constructor(deps: WalletDeps);
|
|
35
|
+
/** The wallet's server id. */
|
|
36
|
+
get id(): number;
|
|
37
|
+
get name(): string;
|
|
38
|
+
get chain(): ApiChain;
|
|
39
|
+
get network(): ApiNetwork;
|
|
40
|
+
/** The underlying server record, e.g. for display. */
|
|
41
|
+
get detail(): ApiWalletDetail;
|
|
42
|
+
/** Prepare, sign locally, and broadcast a withdrawal from one of this wallet's addresses. */
|
|
43
|
+
withdraw(input: WalletWithdrawInput): Promise<ApiWithdrawal>;
|
|
44
|
+
/** Fetch the current state of a withdrawal (e.g. to poll for confirmation). */
|
|
45
|
+
getWithdrawal(withdrawalId: number): Promise<ApiWithdrawal>;
|
|
46
|
+
/** List the addresses registered for this wallet. */
|
|
47
|
+
listAddresses(options?: ListApiAddressOptions): Promise<{
|
|
48
|
+
items: ApiWalletAddress[];
|
|
49
|
+
pageInfo: ApiPageInfo;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Derive and register the next address (uses the server's `nextAccountIndex`).
|
|
53
|
+
* Requires loading the wallet with your encryption password — a key provider
|
|
54
|
+
* can't seal against the server.
|
|
55
|
+
*/
|
|
56
|
+
deriveAddress(options?: DeriveAddressOptions): Promise<DeriveAddressResult>;
|
|
57
|
+
/** Fetch and decrypt this wallet's recovery phrase from the server (audited). */
|
|
58
|
+
revealMnemonic(): Promise<string>;
|
|
59
|
+
/** Wipe the unlocked key material from memory. The wallet can't sign afterwards. */
|
|
60
|
+
lock(): void;
|
|
61
|
+
private requireService;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAChB,eAAe,EAC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+EAA+E;IACzE,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAIjE,qDAAqD;IAC/C,aAAa,CACjB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC;QAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC;QAAC,QAAQ,EAAE,WAAW,CAAA;KAAE,CAAC;IAIhE;;;;OAIG;IACG,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAMrF,iFAAiF;IAC3E,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAIvC,oFAAoF;IACpF,IAAI,IAAI,IAAI;IAIZ,OAAO,CAAC,cAAc;CAQvB"}
|
package/dist/wallet.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ValidationError } from './errors.js';
|
|
2
|
+
import { HotWallet } from './hot-wallet.js';
|
|
3
|
+
import { WalletService } from './wallet-service.js';
|
|
4
|
+
/**
|
|
5
|
+
* A single wallet, ready to use. Returned by {@link Guveno.loadWallet},
|
|
6
|
+
* {@link Guveno.createWallet}, and {@link Guveno.importWallet}. The signing key
|
|
7
|
+
* is already resolved (either the unlocked encryption key, or a key provider), so
|
|
8
|
+
* you can withdraw, derive addresses, and reveal the recovery phrase without
|
|
9
|
+
* re-supplying credentials.
|
|
10
|
+
*/
|
|
11
|
+
export class Wallet {
|
|
12
|
+
api;
|
|
13
|
+
session;
|
|
14
|
+
hot;
|
|
15
|
+
// Only available in encryption-password (session) mode — derive/reveal need to
|
|
16
|
+
// seal/unseal against the server, which a bare key provider can't do.
|
|
17
|
+
service;
|
|
18
|
+
walletDetail;
|
|
19
|
+
constructor(deps) {
|
|
20
|
+
this.api = deps.api;
|
|
21
|
+
this.session = deps.session;
|
|
22
|
+
this.walletDetail = deps.detail;
|
|
23
|
+
this.hot = new HotWallet({
|
|
24
|
+
api: deps.api,
|
|
25
|
+
...(deps.session != null ? { session: deps.session } : {}),
|
|
26
|
+
...(deps.keys != null ? { keys: deps.keys } : {})
|
|
27
|
+
});
|
|
28
|
+
this.service = deps.session != null ? new WalletService({ api: deps.api, session: deps.session }) : undefined;
|
|
29
|
+
}
|
|
30
|
+
/** The wallet's server id. */
|
|
31
|
+
get id() {
|
|
32
|
+
return this.walletDetail.id;
|
|
33
|
+
}
|
|
34
|
+
get name() {
|
|
35
|
+
return this.walletDetail.name;
|
|
36
|
+
}
|
|
37
|
+
get chain() {
|
|
38
|
+
return this.walletDetail.chain;
|
|
39
|
+
}
|
|
40
|
+
get network() {
|
|
41
|
+
return this.walletDetail.network;
|
|
42
|
+
}
|
|
43
|
+
/** The underlying server record, e.g. for display. */
|
|
44
|
+
get detail() {
|
|
45
|
+
return this.walletDetail;
|
|
46
|
+
}
|
|
47
|
+
/** Prepare, sign locally, and broadcast a withdrawal from one of this wallet's addresses. */
|
|
48
|
+
async withdraw(input) {
|
|
49
|
+
return this.hot.withdraw({ ...input, walletId: this.walletDetail.id });
|
|
50
|
+
}
|
|
51
|
+
/** Fetch the current state of a withdrawal (e.g. to poll for confirmation). */
|
|
52
|
+
async getWithdrawal(withdrawalId) {
|
|
53
|
+
return this.api.getWithdrawal(withdrawalId);
|
|
54
|
+
}
|
|
55
|
+
/** List the addresses registered for this wallet. */
|
|
56
|
+
async listAddresses(options = {}) {
|
|
57
|
+
return this.api.listWalletAddresses(this.walletDetail.id, options);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Derive and register the next address (uses the server's `nextAccountIndex`).
|
|
61
|
+
* Requires loading the wallet with your encryption password — a key provider
|
|
62
|
+
* can't seal against the server.
|
|
63
|
+
*/
|
|
64
|
+
async deriveAddress(options = {}) {
|
|
65
|
+
const result = await this.requireService('deriveAddress').deriveAddress(this.walletDetail.id, options);
|
|
66
|
+
this.walletDetail = result.wallet;
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
/** Fetch and decrypt this wallet's recovery phrase from the server (audited). */
|
|
70
|
+
async revealMnemonic() {
|
|
71
|
+
return this.requireService('revealMnemonic').revealMnemonic(this.walletDetail.id);
|
|
72
|
+
}
|
|
73
|
+
/** Wipe the unlocked key material from memory. The wallet can't sign afterwards. */
|
|
74
|
+
lock() {
|
|
75
|
+
this.session?.lock();
|
|
76
|
+
}
|
|
77
|
+
requireService(method) {
|
|
78
|
+
if (this.service == null) {
|
|
79
|
+
throw new ValidationError(`${method}() needs the wallet loaded with your encryption password; it isn't available when signing from a key provider.`);
|
|
80
|
+
}
|
|
81
|
+
return this.service;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAsB,MAAM,iBAAiB,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAuD,MAAM,qBAAqB,CAAC;AAiBzG;;;;;;GAMG;AACH,MAAM,OAAO,MAAM;IACA,GAAG,CAAkB;IACrB,OAAO,CAAgC;IACvC,GAAG,CAAY;IAChC,+EAA+E;IAC/E,sEAAsE;IACrD,OAAO,CAA4B;IAC5C,YAAY,CAAkB;IAEtC,YAAY,IAAgB;QAC1B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;QAChC,IAAI,CAAC,GAAG,GAAG,IAAI,SAAS,CAAC;YACvB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1D,GAAG,C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E,EAAE,OAAO,CAAC,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,aAAa,CAAC,UAAgC,EAAE;QACpD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACvG,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;QAClC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,iFAAiF;IACjF,KAAK,CAAC,cAAc;QAClB,OAAO,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IACpF,CAAC;IAED,oFAAoF;IACpF,IAAI;QACF,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;IACvB,CAAC;IAEO,cAAc,CAAC,MAAc;QACnC,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;YACzB,MAAM,IAAI,eAAe,CACvB,GAAG,MAAM,gHAAgH,CAC1H,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guveno/wallet-sdk",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Add secure crypto custody to your app in minutes — create and manage multi-chain wallets, automate withdrawals, and receive real-time webhooks for Bitcoin, Ethereum, XRP, and Polkadot. Built for exchanges, fintechs, and platforms.",
|
|
5
5
|
"author": "Guveno LLC",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"crypto",
|
|
27
27
|
"custody"
|
|
28
28
|
],
|
|
29
|
-
"homepage": "https://guveno.com",
|
|
29
|
+
"homepage": "https://www.guveno.com/docs",
|
|
30
30
|
"files": [
|
|
31
31
|
"dist",
|
|
32
32
|
"README.md",
|