agent0-sdk 1.1.3 → 1.3.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 +10 -10
- package/dist/core/agent.d.ts +10 -3
- package/dist/core/agent.d.ts.map +1 -1
- package/dist/core/agent.js +56 -10
- package/dist/core/agent.js.map +1 -1
- package/dist/core/contracts.d.ts +36 -5
- package/dist/core/contracts.d.ts.map +1 -1
- package/dist/core/contracts.js +17 -5
- package/dist/core/contracts.js.map +1 -1
- package/dist/core/feedback-manager.d.ts +3 -3
- package/dist/core/feedback-manager.d.ts.map +1 -1
- package/dist/core/feedback-manager.js +29 -23
- package/dist/core/feedback-manager.js.map +1 -1
- package/dist/core/indexer.d.ts +1 -1
- package/dist/core/indexer.js +14 -14
- package/dist/core/indexer.js.map +1 -1
- package/dist/core/sdk.d.ts +2 -2
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +5 -5
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/subgraph-client.d.ts +4 -4
- package/dist/core/subgraph-client.d.ts.map +1 -1
- package/dist/core/subgraph-client.js +20 -20
- package/dist/core/subgraph-client.js.map +1 -1
- package/dist/core/viem-chain-client.d.ts.map +1 -1
- package/dist/core/viem-chain-client.js +7 -4
- package/dist/core/viem-chain-client.js.map +1 -1
- package/dist/models/generated/subgraph-types.d.ts +2 -3
- package/dist/models/generated/subgraph-types.d.ts.map +1 -1
- package/dist/models/interfaces.d.ts +13 -6
- package/dist/models/interfaces.d.ts.map +1 -1
- package/dist/utils/validation.d.ts +1 -1
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +2 -2
- package/dist/utils/validation.js.map +1 -1
- package/dist/utils/value-encoding.d.ts +22 -0
- package/dist/utils/value-encoding.d.ts.map +1 -0
- package/dist/utils/value-encoding.js +133 -0
- package/dist/utils/value-encoding.js.map +1 -0
- package/package.json +1 -1
- package/dist/core/web3-client.d.ts +0 -191
- package/dist/core/web3-client.d.ts.map +0 -1
- package/dist/core/web3-client.js +0 -350
- package/dist/core/web3-client.js.map +0 -1
- package/dist/taxonomies/all_domains.json +0 -1565
- package/dist/taxonomies/all_skills.json +0 -1030
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encode a decimal value (number|string) to ReputationRegistry's (int256 value, uint8 valueDecimals).
|
|
3
|
+
*
|
|
4
|
+
* - Supports negatives
|
|
5
|
+
* - Rounds half-up to at most 18 decimals (never rejects)
|
|
6
|
+
* - Clamps the raw int256 magnitude to <= 1e50 to avoid on-chain reverts
|
|
7
|
+
*/
|
|
8
|
+
export type EncodedReputationValue = {
|
|
9
|
+
value: bigint;
|
|
10
|
+
valueDecimals: number;
|
|
11
|
+
normalized: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Encodes an input decimal to (value,valueDecimals), rounding half-up to <=18 decimals
|
|
15
|
+
* and clamping raw abs(value) to <= 1e50.
|
|
16
|
+
*/
|
|
17
|
+
export declare function encodeReputationValue(input: number | string): EncodedReputationValue;
|
|
18
|
+
/**
|
|
19
|
+
* Compute a JS number from (raw,valueDecimals). Note: may lose precision for very large values.
|
|
20
|
+
*/
|
|
21
|
+
export declare function decodeReputationValue(raw: bigint, valueDecimals: number): number;
|
|
22
|
+
//# sourceMappingURL=value-encoding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-encoding.d.ts","sourceRoot":"","sources":["../../src/utils/value-encoding.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAyEF;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,sBAAsB,CA6CpF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAGhF"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encode a decimal value (number|string) to ReputationRegistry's (int256 value, uint8 valueDecimals).
|
|
3
|
+
*
|
|
4
|
+
* - Supports negatives
|
|
5
|
+
* - Rounds half-up to at most 18 decimals (never rejects)
|
|
6
|
+
* - Clamps the raw int256 magnitude to <= 1e50 to avoid on-chain reverts
|
|
7
|
+
*/
|
|
8
|
+
const MAX_VALUE_DECIMALS = 18;
|
|
9
|
+
const MAX_RAW_ABS = 10n ** 50n; // matches ReputationRegistryUpgradeable MAX_ABS_VALUE = 1e50
|
|
10
|
+
function stripLeadingZeros(s) {
|
|
11
|
+
let i = 0;
|
|
12
|
+
while (i < s.length - 1 && s[i] === '0')
|
|
13
|
+
i++;
|
|
14
|
+
return s.slice(i);
|
|
15
|
+
}
|
|
16
|
+
function normalizeDecimalString(input) {
|
|
17
|
+
const s = input.trim();
|
|
18
|
+
if (s.length === 0)
|
|
19
|
+
throw new Error('Empty value');
|
|
20
|
+
// Reject NaN/Infinity textual forms early
|
|
21
|
+
const lower = s.toLowerCase();
|
|
22
|
+
if (lower === 'nan' || lower === '+nan' || lower === '-nan')
|
|
23
|
+
throw new Error('NaN not supported');
|
|
24
|
+
if (lower === 'infinity' || lower === '+infinity' || lower === '-infinity')
|
|
25
|
+
throw new Error('Infinity not supported');
|
|
26
|
+
// Handle exponential notation (e.g. 1.23e-4)
|
|
27
|
+
if (/[eE]/.test(s)) {
|
|
28
|
+
const match = s.match(/^([+-]?)(\d+(?:\.\d+)?)[eE]([+-]?\d+)$/);
|
|
29
|
+
if (!match)
|
|
30
|
+
throw new Error(`Invalid numeric string: ${input}`);
|
|
31
|
+
const sign = match[1] === '-' ? '-' : '';
|
|
32
|
+
const mantissa = match[2];
|
|
33
|
+
const exp = parseInt(match[3], 10);
|
|
34
|
+
if (!Number.isFinite(exp))
|
|
35
|
+
throw new Error(`Invalid exponent: ${input}`);
|
|
36
|
+
const [intPartRaw, fracPartRaw = ''] = mantissa.split('.');
|
|
37
|
+
const digits = stripLeadingZeros((intPartRaw || '0') + fracPartRaw);
|
|
38
|
+
const fracLen = fracPartRaw.length;
|
|
39
|
+
// mantissa represents digits * 10^-fracLen. Apply exponent => shift by (exp - fracLen).
|
|
40
|
+
const shift = exp - fracLen;
|
|
41
|
+
if (digits === '0')
|
|
42
|
+
return '0';
|
|
43
|
+
if (shift >= 0) {
|
|
44
|
+
return sign + digits + '0'.repeat(shift);
|
|
45
|
+
}
|
|
46
|
+
// shift < 0 => decimal point moves left
|
|
47
|
+
const pos = digits.length + shift; // shift negative
|
|
48
|
+
if (pos > 0) {
|
|
49
|
+
const a = digits.slice(0, pos);
|
|
50
|
+
const b = digits.slice(pos);
|
|
51
|
+
return sign + a + '.' + b;
|
|
52
|
+
}
|
|
53
|
+
// Need leading zeros: 0.xxx
|
|
54
|
+
return sign + '0.' + '0'.repeat(-pos) + digits;
|
|
55
|
+
}
|
|
56
|
+
// Plain decimal
|
|
57
|
+
if (!/^([+-])?(\d+)(\.\d+)?$/.test(s)) {
|
|
58
|
+
throw new Error(`Invalid numeric string: ${input}`);
|
|
59
|
+
}
|
|
60
|
+
// Normalize: remove leading +, trim trailing fractional zeros
|
|
61
|
+
let sign = '';
|
|
62
|
+
let body = s;
|
|
63
|
+
if (body[0] === '+')
|
|
64
|
+
body = body.slice(1);
|
|
65
|
+
if (body[0] === '-') {
|
|
66
|
+
sign = '-';
|
|
67
|
+
body = body.slice(1);
|
|
68
|
+
}
|
|
69
|
+
let [intPart, fracPart = ''] = body.split('.');
|
|
70
|
+
intPart = stripLeadingZeros(intPart || '0');
|
|
71
|
+
fracPart = fracPart.replace(/0+$/, '');
|
|
72
|
+
if (intPart === '0' && fracPart.length === 0)
|
|
73
|
+
return '0';
|
|
74
|
+
return sign + intPart + (fracPart.length ? '.' + fracPart : '');
|
|
75
|
+
}
|
|
76
|
+
function pow10BigInt(decimals) {
|
|
77
|
+
return 10n ** BigInt(decimals);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Encodes an input decimal to (value,valueDecimals), rounding half-up to <=18 decimals
|
|
81
|
+
* and clamping raw abs(value) to <= 1e50.
|
|
82
|
+
*/
|
|
83
|
+
export function encodeReputationValue(input) {
|
|
84
|
+
let normalized;
|
|
85
|
+
if (typeof input === 'number') {
|
|
86
|
+
if (!Number.isFinite(input))
|
|
87
|
+
throw new Error('Non-finite number not supported');
|
|
88
|
+
// Convert number to a decimal string; toString may yield exponent form, which we normalize above.
|
|
89
|
+
// Keep plenty of precision; downstream we round to <=18 decimals anyway.
|
|
90
|
+
normalized = normalizeDecimalString(input.toString());
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
normalized = normalizeDecimalString(input);
|
|
94
|
+
}
|
|
95
|
+
if (normalized === '0') {
|
|
96
|
+
return { value: 0n, valueDecimals: 0, normalized };
|
|
97
|
+
}
|
|
98
|
+
const negative = normalized.startsWith('-');
|
|
99
|
+
const unsigned = negative ? normalized.slice(1) : normalized;
|
|
100
|
+
const [intPart, fracPartRaw = ''] = unsigned.split('.');
|
|
101
|
+
// Decide decimals to encode (<=18), then round half-up if needed.
|
|
102
|
+
const fracPart = fracPartRaw;
|
|
103
|
+
const decimals = Math.min(fracPart.length, MAX_VALUE_DECIMALS);
|
|
104
|
+
const kept = fracPart.slice(0, decimals);
|
|
105
|
+
const nextDigit = fracPart.length > decimals ? fracPart.charCodeAt(decimals) - 48 : 0;
|
|
106
|
+
// Build the raw scaled integer string
|
|
107
|
+
const scaledStr = stripLeadingZeros((intPart || '0') + kept.padEnd(decimals, '0')) || '0';
|
|
108
|
+
let raw = BigInt(scaledStr);
|
|
109
|
+
// Round half-up at the next digit beyond `decimals`
|
|
110
|
+
const shouldRoundUp = fracPart.length > decimals && nextDigit >= 5;
|
|
111
|
+
if (shouldRoundUp)
|
|
112
|
+
raw = raw + 1n;
|
|
113
|
+
if (negative)
|
|
114
|
+
raw = -raw;
|
|
115
|
+
// Clamp to on-chain bounds for raw int256 value
|
|
116
|
+
if (raw > MAX_RAW_ABS)
|
|
117
|
+
raw = MAX_RAW_ABS;
|
|
118
|
+
if (raw < -MAX_RAW_ABS)
|
|
119
|
+
raw = -MAX_RAW_ABS;
|
|
120
|
+
return {
|
|
121
|
+
value: raw,
|
|
122
|
+
valueDecimals: decimals,
|
|
123
|
+
normalized,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Compute a JS number from (raw,valueDecimals). Note: may lose precision for very large values.
|
|
128
|
+
*/
|
|
129
|
+
export function decodeReputationValue(raw, valueDecimals) {
|
|
130
|
+
const denom = Number(pow10BigInt(valueDecimals));
|
|
131
|
+
return Number(raw) / denom;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=value-encoding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-encoding.js","sourceRoot":"","sources":["../../src/utils/value-encoding.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,WAAW,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,6DAA6D;AAQ7F,SAAS,iBAAiB,CAAC,CAAS;IAClC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG;QAAE,CAAC,EAAE,CAAC;IAC7C,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAED,SAAS,sBAAsB,CAAC,KAAa;IAC3C,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IACvB,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;IAEnD,0CAA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AqB,CAAC,GAAW,EAAE,aAAqB;IACtE,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;IACjD,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAC7B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Web3 integration layer for smart contract interactions using ethers.js
|
|
3
|
-
*/
|
|
4
|
-
import { ethers, type Contract, type Wallet, type Signer, type JsonRpcProvider, type InterfaceAbi } from 'ethers';
|
|
5
|
-
export interface TransactionOptions {
|
|
6
|
-
gasLimit?: bigint;
|
|
7
|
-
gasPrice?: bigint;
|
|
8
|
-
maxFeePerGas?: bigint;
|
|
9
|
-
maxPriorityFeePerGas?: bigint;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Web3 client for interacting with ERC-8004 smart contracts
|
|
13
|
-
*/
|
|
14
|
-
export declare class Web3Client {
|
|
15
|
-
readonly provider: JsonRpcProvider;
|
|
16
|
-
readonly signer?: Wallet | Signer;
|
|
17
|
-
chainId: bigint;
|
|
18
|
-
/**
|
|
19
|
-
* Initialize Web3 client
|
|
20
|
-
* @param rpcUrl - RPC endpoint URL
|
|
21
|
-
* @param signerOrKey - Optional private key string OR ethers Wallet/Signer for signing transactions
|
|
22
|
-
*/
|
|
23
|
-
constructor(rpcUrl: string, signerOrKey?: string | Wallet | Signer);
|
|
24
|
-
/**
|
|
25
|
-
* Initialize the client (fetch chain ID)
|
|
26
|
-
*/
|
|
27
|
-
initialize(): Promise<void>;
|
|
28
|
-
/**
|
|
29
|
-
* Get contract instance
|
|
30
|
-
*/
|
|
31
|
-
getContract(address: string, abi: InterfaceAbi): Contract;
|
|
32
|
-
/**
|
|
33
|
-
* Call a contract method (view/pure function)
|
|
34
|
-
*/
|
|
35
|
-
callContract(contract: Contract, methodName: string, ...args: any[]): Promise<any>;
|
|
36
|
-
/**
|
|
37
|
-
* Execute a contract transaction
|
|
38
|
-
* For overloaded functions like register(), use registerAgent() wrapper instead
|
|
39
|
-
*/
|
|
40
|
-
transactContract(contract: Contract, methodName: string, options?: TransactionOptions, ...args: any[]): Promise<string>;
|
|
41
|
-
/**
|
|
42
|
-
* Router wrapper for register() function overloads
|
|
43
|
-
* Intelligently selects the correct overload based on arguments:
|
|
44
|
-
* - register() - no arguments
|
|
45
|
-
* - register(string agentURI) - just agentURI
|
|
46
|
-
* - register(string agentURI, tuple[] metadata) - agentURI + metadata
|
|
47
|
-
*/
|
|
48
|
-
private registerAgent;
|
|
49
|
-
/**
|
|
50
|
-
* Wait for transaction to be mined
|
|
51
|
-
*/
|
|
52
|
-
waitForTransaction(txHash: string, timeout?: number): Promise<ethers.ContractTransactionReceipt>;
|
|
53
|
-
/**
|
|
54
|
-
* Get contract events
|
|
55
|
-
*/
|
|
56
|
-
getEvents(contract: Contract, eventName: string, fromBlock?: number, toBlock?: number): Promise<ethers.Log[]>;
|
|
57
|
-
/**
|
|
58
|
-
* Sign a message with the account's private key
|
|
59
|
-
*/
|
|
60
|
-
signMessage(message: string | Uint8Array): Promise<string>;
|
|
61
|
-
/**
|
|
62
|
-
* Sign typed data (EIP-712) with the account's private key
|
|
63
|
-
*/
|
|
64
|
-
signTypedData(domain: {
|
|
65
|
-
name?: string;
|
|
66
|
-
version?: string;
|
|
67
|
-
chainId?: number | bigint;
|
|
68
|
-
verifyingContract?: string;
|
|
69
|
-
salt?: string;
|
|
70
|
-
}, types: Record<string, any>, value: Record<string, any>): Promise<string>;
|
|
71
|
-
/**
|
|
72
|
-
* Build canonical EIP-712 typed data for IdentityRegistry.setAgentWallet (ERC-8004 Jan 2026).
|
|
73
|
-
*
|
|
74
|
-
* Contract expects:
|
|
75
|
-
* - domain: name="ERC8004IdentityRegistry", version="1"
|
|
76
|
-
* - primary type: AgentWalletSet(uint256 agentId,address newWallet,address owner,uint256 deadline)
|
|
77
|
-
*/
|
|
78
|
-
buildAgentWalletSetTypedData(params: {
|
|
79
|
-
agentId: bigint;
|
|
80
|
-
newWallet: string;
|
|
81
|
-
owner: string;
|
|
82
|
-
deadline: bigint;
|
|
83
|
-
chainId: number | bigint;
|
|
84
|
-
verifyingContract: string;
|
|
85
|
-
domainName?: string;
|
|
86
|
-
domainVersion?: string;
|
|
87
|
-
}): {
|
|
88
|
-
domain: {
|
|
89
|
-
name: string;
|
|
90
|
-
version: string;
|
|
91
|
-
chainId: number | bigint;
|
|
92
|
-
verifyingContract: string;
|
|
93
|
-
};
|
|
94
|
-
types: {
|
|
95
|
-
AgentWalletSet: Array<{
|
|
96
|
-
name: string;
|
|
97
|
-
type: string;
|
|
98
|
-
}>;
|
|
99
|
-
};
|
|
100
|
-
message: {
|
|
101
|
-
agentId: bigint;
|
|
102
|
-
newWallet: string;
|
|
103
|
-
owner: string;
|
|
104
|
-
deadline: bigint;
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* Legacy typed-data variant (without owner field).
|
|
109
|
-
* Some deployments may use AgentWalletSet(uint256 agentId,address newWallet,uint256 deadline).
|
|
110
|
-
*/
|
|
111
|
-
buildAgentWalletSetTypedDataNoOwner(params: {
|
|
112
|
-
agentId: bigint;
|
|
113
|
-
newWallet: string;
|
|
114
|
-
deadline: bigint;
|
|
115
|
-
chainId: number | bigint;
|
|
116
|
-
verifyingContract: string;
|
|
117
|
-
domainName?: string;
|
|
118
|
-
domainVersion?: string;
|
|
119
|
-
}): {
|
|
120
|
-
domain: {
|
|
121
|
-
name: string;
|
|
122
|
-
version: string;
|
|
123
|
-
chainId: number | bigint;
|
|
124
|
-
verifyingContract: string;
|
|
125
|
-
};
|
|
126
|
-
types: {
|
|
127
|
-
AgentWalletSet: Array<{
|
|
128
|
-
name: string;
|
|
129
|
-
type: string;
|
|
130
|
-
}>;
|
|
131
|
-
};
|
|
132
|
-
message: {
|
|
133
|
-
agentId: bigint;
|
|
134
|
-
newWallet: string;
|
|
135
|
-
deadline: bigint;
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
/**
|
|
139
|
-
* Sign EIP-712 typed data with either:
|
|
140
|
-
* - a private key string (EOA), or
|
|
141
|
-
* - an ethers Signer (EOA / smart account with a signer abstraction).
|
|
142
|
-
*/
|
|
143
|
-
signTypedDataWith(signerOrKey: string | Wallet | Signer, domain: Record<string, any>, types: Record<string, any>, message: Record<string, any>): Promise<string>;
|
|
144
|
-
/**
|
|
145
|
-
* Normalize ECDSA signatures to use v = 27/28 (some contracts/libraries expect this).
|
|
146
|
-
* ethers may produce signatures with v in {0,1}.
|
|
147
|
-
*/
|
|
148
|
-
normalizeEcdsaSignature(signature: string): string;
|
|
149
|
-
/**
|
|
150
|
-
* Recover the signer address for EIP-712 typed data (EOA path).
|
|
151
|
-
*/
|
|
152
|
-
recoverTypedDataSigner(domain: Record<string, any>, types: Record<string, any>, message: Record<string, any>, signature: string): string;
|
|
153
|
-
/**
|
|
154
|
-
* Resolve an address for a provided signer or private key string.
|
|
155
|
-
*/
|
|
156
|
-
addressOf(signerOrKey: string | Wallet | Signer): Promise<string>;
|
|
157
|
-
/**
|
|
158
|
-
* Recover address from message and signature
|
|
159
|
-
*/
|
|
160
|
-
recoverAddress(message: string | Uint8Array, signature: string): string;
|
|
161
|
-
/**
|
|
162
|
-
* Compute Keccak-256 hash
|
|
163
|
-
*/
|
|
164
|
-
keccak256(data: string | Uint8Array): string;
|
|
165
|
-
/**
|
|
166
|
-
* Convert address to checksum format
|
|
167
|
-
*/
|
|
168
|
-
toChecksumAddress(address: string): string;
|
|
169
|
-
/**
|
|
170
|
-
* Check if string is a valid Ethereum address
|
|
171
|
-
*/
|
|
172
|
-
isAddress(address: string): boolean;
|
|
173
|
-
/**
|
|
174
|
-
* Get ETH balance of an address
|
|
175
|
-
*/
|
|
176
|
-
getBalance(address: string): Promise<bigint>;
|
|
177
|
-
/**
|
|
178
|
-
* Get transaction count (nonce) of an address
|
|
179
|
-
*/
|
|
180
|
-
getTransactionCount(address: string): Promise<number>;
|
|
181
|
-
/**
|
|
182
|
-
* Get the account address (if signer is available)
|
|
183
|
-
*/
|
|
184
|
-
get address(): string | undefined;
|
|
185
|
-
/**
|
|
186
|
-
* Get the account address asynchronously (if signer is available)
|
|
187
|
-
* Use this method when you need the address from a generic Signer
|
|
188
|
-
*/
|
|
189
|
-
getAddress(): Promise<string | undefined>;
|
|
190
|
-
}
|
|
191
|
-
//# sourceMappingURL=web3-client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web3-client.d.ts","sourceRoot":"","sources":["../../src/core/web3-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,MAAM,EACN,KAAK,QAAQ,EACb,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,QAAQ,CAAC;AAEhB,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,qBAAa,UAAU;IACrB,SAAgB,QAAQ,EAAE,eAAe,CAAC;IAC1C,SAAgB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;gBACS,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IAoClE;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,GAAG,QAAQ;IAKzD;;OAEG;IACG,YAAY,CAChB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,MAAM,EAClB,GAAG,IAAI,EAAE,GAAG,EAAE,GACb,OAA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