@safe-global/api-kit 2.3.2 → 2.4.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/LICENSE.md +1 -1
- package/README.md +18 -278
- package/dist/src/SafeApiKit.d.ts +27 -1
- package/dist/src/SafeApiKit.js +106 -11
- package/dist/src/SafeApiKit.js.map +1 -1
- package/dist/src/types/safeTransactionServiceTypes.d.ts +69 -1
- package/dist/src/utils/constants.d.ts +1 -0
- package/dist/src/utils/constants.js +5 -0
- package/dist/src/utils/constants.js.map +1 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.js +7 -0
- package/dist/src/utils/index.js.map +1 -0
- package/dist/src/utils/signDelegate.d.ts +2 -0
- package/dist/src/utils/signDelegate.js +30 -0
- package/dist/src/utils/signDelegate.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +11 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Signer, TypedDataDomain, TypedDataField } from 'ethers';
|
|
2
|
-
import { SafeMultisigTransactionResponse, SafeTransactionData } from '@safe-global/safe-core-sdk-types';
|
|
2
|
+
import { SafeMultisigTransactionResponse, SafeTransactionData, UserOperation } from '@safe-global/safe-core-sdk-types';
|
|
3
3
|
export type SafeServiceInfoResponse = {
|
|
4
4
|
readonly name: string;
|
|
5
5
|
readonly version: string;
|
|
@@ -244,3 +244,71 @@ export type EIP712TypedData = {
|
|
|
244
244
|
types: TypedDataField;
|
|
245
245
|
message: Record<string, unknown>;
|
|
246
246
|
};
|
|
247
|
+
export type SafeOperationConfirmation = {
|
|
248
|
+
readonly created: string;
|
|
249
|
+
readonly modified: string;
|
|
250
|
+
readonly owner: string;
|
|
251
|
+
readonly signature: string;
|
|
252
|
+
readonly signatureType: string;
|
|
253
|
+
};
|
|
254
|
+
export type UserOperationResponse = {
|
|
255
|
+
readonly ethereumTxHash: string;
|
|
256
|
+
readonly sender: string;
|
|
257
|
+
readonly userOperationHash: string;
|
|
258
|
+
readonly nonce: number;
|
|
259
|
+
readonly initCode: null | string;
|
|
260
|
+
readonly callData: null | string;
|
|
261
|
+
readonly callDataGasLimit: number;
|
|
262
|
+
readonly verificationGasLimit: number;
|
|
263
|
+
readonly preVerificationGas: number;
|
|
264
|
+
readonly maxFeePerGas: number;
|
|
265
|
+
readonly maxPriorityFeePerGas: number;
|
|
266
|
+
readonly paymaster: null | string;
|
|
267
|
+
readonly paymasterData: null | string;
|
|
268
|
+
readonly signature: string;
|
|
269
|
+
readonly entryPoint: string;
|
|
270
|
+
};
|
|
271
|
+
export type SafeOperationResponse = {
|
|
272
|
+
readonly created: string;
|
|
273
|
+
readonly modified: string;
|
|
274
|
+
readonly safeOperationHash: string;
|
|
275
|
+
readonly validAfter: string;
|
|
276
|
+
readonly validUntil: string;
|
|
277
|
+
readonly moduleAddress: string;
|
|
278
|
+
readonly confirmations?: Array<SafeOperationConfirmation>;
|
|
279
|
+
readonly preparedSignature?: string;
|
|
280
|
+
readonly userOperation?: UserOperationResponse;
|
|
281
|
+
};
|
|
282
|
+
export type GetSafeOperationListProps = {
|
|
283
|
+
/** Address of the Safe to get SafeOperations for */
|
|
284
|
+
safeAddress: string;
|
|
285
|
+
/** Which field to use when ordering the results */
|
|
286
|
+
ordering?: string;
|
|
287
|
+
/** Maximum number of results to return per page */
|
|
288
|
+
limit?: string;
|
|
289
|
+
/** Initial index from which to return the results */
|
|
290
|
+
offset?: string;
|
|
291
|
+
};
|
|
292
|
+
export type GetSafeOperationListResponse = {
|
|
293
|
+
readonly count: number;
|
|
294
|
+
readonly next?: string;
|
|
295
|
+
readonly previous?: string;
|
|
296
|
+
readonly results: Array<SafeOperationResponse>;
|
|
297
|
+
};
|
|
298
|
+
export type AddSafeOperationProps = {
|
|
299
|
+
/** Address of the EntryPoint contract */
|
|
300
|
+
entryPoint: string;
|
|
301
|
+
/** Address of the Safe4337Module contract */
|
|
302
|
+
moduleAddress: string;
|
|
303
|
+
/** Address of the Safe to add a SafeOperation for */
|
|
304
|
+
safeAddress: string;
|
|
305
|
+
/** UserOperation object to add */
|
|
306
|
+
userOperation: UserOperation;
|
|
307
|
+
/** Options object */
|
|
308
|
+
options?: {
|
|
309
|
+
/** The UserOperation will remain valid until this block's timestamp */
|
|
310
|
+
validUntil?: number;
|
|
311
|
+
/** The UserOperation will be valid after this block's timestamp */
|
|
312
|
+
validAfter?: number;
|
|
313
|
+
};
|
|
314
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EMPTY_DATA = "0x";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/utils/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,IAAI,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isEmptyData: (input: string) => boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEmptyData = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const isEmptyData = (input) => !input || input === constants_1.EMPTY_DATA;
|
|
6
|
+
exports.isEmptyData = isEmptyData;
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAEjC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,KAAK,KAAK,sBAAU,CAAA;AAA/D,QAAA,WAAW,eAAoD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signDelegate = void 0;
|
|
4
|
+
// TODO: remove this function in favor of viem#pad
|
|
5
|
+
function padHex(hex, { dir = 'left', size = 32 } = {}) {
|
|
6
|
+
if (size === null)
|
|
7
|
+
return hex;
|
|
8
|
+
const result = hex.replace('0x', '');
|
|
9
|
+
if (result.length > size * 2)
|
|
10
|
+
throw new Error(`Size (${result.length}) exceeds padding size.`);
|
|
11
|
+
return `0x${result[dir === 'right' ? 'padEnd' : 'padStart'](size * 2, '0')}`;
|
|
12
|
+
}
|
|
13
|
+
async function signDelegate(signer, delegateAddress, chainId) {
|
|
14
|
+
const domain = {
|
|
15
|
+
name: 'Safe Transaction Service',
|
|
16
|
+
version: '1.0',
|
|
17
|
+
chainId: chainId
|
|
18
|
+
};
|
|
19
|
+
const types = {
|
|
20
|
+
Delegate: [
|
|
21
|
+
{ name: 'delegateAddress', type: 'bytes32' },
|
|
22
|
+
{ name: 'totp', type: 'uint256' }
|
|
23
|
+
]
|
|
24
|
+
};
|
|
25
|
+
const totp = Math.floor(Date.now() / 1000 / 3600);
|
|
26
|
+
const paddedAddress = padHex(delegateAddress, { size: 32, dir: 'right' });
|
|
27
|
+
return await signer.signTypedData(domain, types, { delegateAddress: paddedAddress, totp });
|
|
28
|
+
}
|
|
29
|
+
exports.signDelegate = signDelegate;
|
|
30
|
+
//# sourceMappingURL=signDelegate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signDelegate.js","sourceRoot":"","sources":["../../../src/utils/signDelegate.ts"],"names":[],"mappings":";;;AAEA,kDAAkD;AAClD,SAAS,MAAM,CACb,GAAW,EACX,EAAE,GAAG,GAAG,MAAM,EAAE,IAAI,GAAG,EAAE,KAAsC,EAAE;IAEjE,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,GAAG,CAAA;IAC7B,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;IACpC,IAAI,MAAM,CAAC,MAAM,GAAG,IAAI,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,SAAS,MAAM,CAAC,MAAM,yBAAyB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