@safe-global/api-kit
Advanced tools
Comparing version 2.4.2 to 2.4.3
@@ -1,3 +0,3 @@ | ||
import { AddMessageProps, AddSafeDelegateProps, AddSafeOperationProps, AllTransactionsListResponse, AllTransactionsOptions, DeleteSafeDelegateProps, GetSafeDelegateProps, GetSafeOperationListProps, GetSafeOperationListResponse, SafeSingletonResponse, GetSafeMessageListProps, ModulesResponse, OwnerResponse, ProposeTransactionProps, SafeCreationInfoResponse, SafeDelegateListResponse, SafeDelegateResponse, SafeInfoResponse, SafeMessage, SafeMessageListResponse, SafeModuleTransactionListResponse, SafeMultisigTransactionEstimate, SafeMultisigTransactionEstimateResponse, SafeMultisigTransactionListResponse, SafeServiceInfoResponse, SignatureResponse, TokenInfoListResponse, TokenInfoResponse, TransferListResponse } from './types/safeTransactionServiceTypes'; | ||
import { SafeMultisigConfirmationListResponse, SafeMultisigTransactionResponse, SafeOperationResponse, SafeOperation } from '@safe-global/safe-core-sdk-types'; | ||
import { AddMessageProps, AddSafeDelegateProps, AddSafeOperationProps, AllTransactionsListResponse, AllTransactionsOptions, DeleteSafeDelegateProps, GetSafeDelegateProps, GetSafeMessageListProps, GetSafeOperationListProps, GetSafeOperationListResponse, ListOptions, ModulesResponse, OwnerResponse, ProposeTransactionProps, SafeCreationInfoResponse, SafeDelegateListResponse, SafeInfoResponse, SafeMessage, SafeMessageListResponse, SafeModuleTransactionListResponse, SafeMultisigTransactionEstimate, SafeMultisigTransactionEstimateResponse, SafeMultisigTransactionListResponse, SafeServiceInfoResponse, SafeSingletonResponse, SignatureResponse, SignedSafeDelegateResponse, TokenInfoListResponse, TokenInfoResponse, TransferListResponse } from './types/safeTransactionServiceTypes'; | ||
import { SafeMultisigConfirmationListResponse, SafeMultisigTransactionResponse, SafeOperation, SafeOperationConfirmationListResponse, SafeOperationResponse } from '@safe-global/safe-core-sdk-types'; | ||
export interface SafeApiKitConfig { | ||
@@ -111,3 +111,3 @@ /** chainId - The chainId */ | ||
*/ | ||
addSafeDelegate({ safeAddress, delegateAddress, delegatorAddress, label, signer }: AddSafeDelegateProps): Promise<SafeDelegateResponse>; | ||
addSafeDelegate({ safeAddress, delegateAddress, delegatorAddress, label, signer }: AddSafeDelegateProps): Promise<SignedSafeDelegateResponse>; | ||
/** | ||
@@ -284,3 +284,25 @@ * Removes a delegate for a given Safe address. | ||
addSafeOperation(safeOperation: AddSafeOperationProps | SafeOperation): Promise<void>; | ||
/** | ||
* Returns the list of confirmations for a given a SafeOperation. | ||
* | ||
* @param safeOperationHash - The hash of the SafeOperation to get confirmations for | ||
* @param getSafeOperationConfirmationsOptions - Additional options for fetching the list of confirmations | ||
* @returns The list of confirmations | ||
* @throws "Invalid SafeOperation hash" | ||
* @throws "Invalid data" | ||
*/ | ||
getSafeOperationConfirmations(safeOperationHash: string, { limit, offset }?: ListOptions): Promise<SafeOperationConfirmationListResponse>; | ||
/** | ||
* Adds a confirmation for a SafeOperation. | ||
* | ||
* @param safeOperationHash The SafeOperation hash | ||
* @param signature - Signature of the SafeOperation | ||
* @returns | ||
* @throws "Invalid SafeOperation hash" | ||
* @throws "Invalid signature" | ||
* @throws "Malformed data" | ||
* @throws "Error processing data" | ||
*/ | ||
confirmSafeOperation(safeOperationHash: string, signature: string): Promise<void>; | ||
} | ||
export default SafeApiKit; |
@@ -217,7 +217,7 @@ "use strict"; | ||
} | ||
if (limit) { | ||
url.searchParams.set('limit', limit); | ||
if (limit != null) { | ||
url.searchParams.set('limit', limit.toString()); | ||
} | ||
if (offset) { | ||
url.searchParams.set('offset', offset); | ||
if (offset != null) { | ||
url.searchParams.set('offset', offset.toString()); | ||
} | ||
@@ -552,7 +552,7 @@ return (0, httpRequests_1.sendRequest)({ | ||
} | ||
if (limit) { | ||
url.searchParams.set('limit', limit); | ||
if (limit != null) { | ||
url.searchParams.set('limit', limit.toString()); | ||
} | ||
if (offset) { | ||
url.searchParams.set('offset', offset); | ||
if (offset != null) { | ||
url.searchParams.set('offset', offset.toString()); | ||
} | ||
@@ -613,7 +613,7 @@ return (0, httpRequests_1.sendRequest)({ | ||
} | ||
if (limit) { | ||
url.searchParams.set('limit', limit); | ||
if (limit != null) { | ||
url.searchParams.set('limit', limit.toString()); | ||
} | ||
if (offset) { | ||
url.searchParams.set('offset', offset); | ||
if (offset != null) { | ||
url.searchParams.set('offset', offset.toString()); | ||
} | ||
@@ -681,2 +681,4 @@ return (0, httpRequests_1.sendRequest)({ | ||
} | ||
// We are receiving the timestamp in seconds (block timestamp), but the API expects it in milliseconds | ||
const getISOString = (date) => !date ? null : new Date(date * 1000).toISOString(); | ||
return (0, httpRequests_1.sendRequest)({ | ||
@@ -698,4 +700,4 @@ url: `${__classPrivateFieldGet(this, _SafeApiKit_txServiceBaseUrl, "f")}/v1/safes/${safeAddress}/safe-operations/`, | ||
entryPoint, | ||
validAfter: !options?.validAfter ? null : options?.validAfter, | ||
validUntil: !options?.validUntil ? null : options?.validUntil, | ||
validAfter: getISOString(options?.validAfter), | ||
validUntil: getISOString(options?.validUntil), | ||
signature: userOperation.signature, | ||
@@ -706,2 +708,51 @@ moduleAddress | ||
} | ||
/** | ||
* Returns the list of confirmations for a given a SafeOperation. | ||
* | ||
* @param safeOperationHash - The hash of the SafeOperation to get confirmations for | ||
* @param getSafeOperationConfirmationsOptions - Additional options for fetching the list of confirmations | ||
* @returns The list of confirmations | ||
* @throws "Invalid SafeOperation hash" | ||
* @throws "Invalid data" | ||
*/ | ||
async getSafeOperationConfirmations(safeOperationHash, { limit, offset } = {}) { | ||
if (!safeOperationHash) { | ||
throw new Error('Invalid SafeOperation hash'); | ||
} | ||
const url = new URL(`${__classPrivateFieldGet(this, _SafeApiKit_txServiceBaseUrl, "f")}/v1/safe-operations/${safeOperationHash}/confirmations/`); | ||
if (limit != null) { | ||
url.searchParams.set('limit', limit.toString()); | ||
} | ||
if (offset != null) { | ||
url.searchParams.set('offset', offset.toString()); | ||
} | ||
return (0, httpRequests_1.sendRequest)({ | ||
url: url.toString(), | ||
method: httpRequests_1.HttpMethod.Get | ||
}); | ||
} | ||
/** | ||
* Adds a confirmation for a SafeOperation. | ||
* | ||
* @param safeOperationHash The SafeOperation hash | ||
* @param signature - Signature of the SafeOperation | ||
* @returns | ||
* @throws "Invalid SafeOperation hash" | ||
* @throws "Invalid signature" | ||
* @throws "Malformed data" | ||
* @throws "Error processing data" | ||
*/ | ||
async confirmSafeOperation(safeOperationHash, signature) { | ||
if (!safeOperationHash) { | ||
throw new Error('Invalid SafeOperation hash'); | ||
} | ||
if (!signature) { | ||
throw new Error('Invalid signature'); | ||
} | ||
return (0, httpRequests_1.sendRequest)({ | ||
url: `${__classPrivateFieldGet(this, _SafeApiKit_txServiceBaseUrl, "f")}/v1/safe-operations/${safeOperationHash}/confirmations/`, | ||
method: httpRequests_1.HttpMethod.Post, | ||
body: { signature } | ||
}); | ||
} | ||
} | ||
@@ -708,0 +759,0 @@ _SafeApiKit_chainId = new WeakMap(), _SafeApiKit_txServiceBaseUrl = new WeakMap(), _SafeApiKit_instances = new WeakSet(), _SafeApiKit_isValidAddress = function _SafeApiKit_isValidAddress(address) { |
import { Signer, TypedDataDomain, TypedDataField } from 'ethers'; | ||
import { SafeMultisigTransactionResponse, SafeTransactionData, UserOperation, SafeOperationResponse } from '@safe-global/safe-core-sdk-types'; | ||
import { SafeMultisigTransactionResponse, SafeTransactionData, UserOperation, SafeOperationResponse, ListResponse } from '@safe-global/safe-core-sdk-types'; | ||
export type ListOptions = { | ||
/** Maximum number of results to return per page */ | ||
limit?: number; | ||
/** Initial index from which to return the results */ | ||
offset?: number; | ||
}; | ||
export type SafeServiceInfoResponse = { | ||
@@ -55,5 +61,3 @@ readonly name: string; | ||
label?: string; | ||
limit?: string; | ||
offset?: string; | ||
}; | ||
} & ListOptions; | ||
export type AddSafeDelegateProps = { | ||
@@ -76,15 +80,7 @@ safeAddress?: string; | ||
readonly label: string; | ||
}; | ||
export type SignedSafeDelegateResponse = SafeDelegateResponse & { | ||
readonly signature: string; | ||
}; | ||
export type SafeDelegateListResponse = { | ||
readonly count: number; | ||
readonly next?: string; | ||
readonly previous?: string; | ||
readonly results: { | ||
readonly safe: string; | ||
readonly delegate: string; | ||
readonly delegator: string; | ||
readonly label: string; | ||
}[]; | ||
}; | ||
export type SafeDelegateListResponse = ListResponse<SafeDelegateResponse>; | ||
export type SafeMultisigTransactionEstimate = { | ||
@@ -110,8 +106,3 @@ readonly to: string; | ||
}; | ||
export type SafeMultisigTransactionListResponse = { | ||
readonly count: number; | ||
readonly next?: string; | ||
readonly previous?: string; | ||
readonly results: SafeMultisigTransactionResponse[]; | ||
}; | ||
export type SafeMultisigTransactionListResponse = ListResponse<SafeMultisigTransactionResponse>; | ||
export type TransferResponse = { | ||
@@ -128,8 +119,3 @@ readonly type?: string; | ||
}; | ||
export type TransferListResponse = { | ||
readonly count: number; | ||
readonly next?: string; | ||
readonly previous?: string; | ||
readonly results: TransferResponse[]; | ||
}; | ||
export type TransferListResponse = ListResponse<TransferResponse>; | ||
export type SafeModuleTransaction = { | ||
@@ -149,8 +135,3 @@ readonly created?: string; | ||
}; | ||
export type SafeModuleTransactionListResponse = { | ||
readonly count: number; | ||
readonly next?: string; | ||
readonly previous?: string; | ||
readonly results: SafeModuleTransaction[]; | ||
}; | ||
export type SafeModuleTransactionListResponse = ListResponse<SafeModuleTransaction>; | ||
export type Erc20Info = { | ||
@@ -170,8 +151,3 @@ readonly name: string; | ||
}; | ||
export type TokenInfoListResponse = { | ||
readonly count: number; | ||
readonly next?: string; | ||
readonly previous?: string; | ||
readonly results: TokenInfoResponse[]; | ||
}; | ||
export type TokenInfoListResponse = ListResponse<TokenInfoResponse>; | ||
export type TransferWithTokenInfoResponse = TransferResponse & { | ||
@@ -205,8 +181,3 @@ readonly tokenInfo: TokenInfoResponse; | ||
}; | ||
export type AllTransactionsListResponse = { | ||
readonly count: number; | ||
readonly next?: string; | ||
readonly previous?: string; | ||
readonly results: Array<SafeModuleTransactionWithTransfersResponse | SafeMultisigTransactionWithTransfersResponse | EthereumTxWithTransfersResponse>; | ||
}; | ||
export type AllTransactionsListResponse = ListResponse<SafeModuleTransactionWithTransfersResponse | SafeMultisigTransactionWithTransfersResponse | EthereumTxWithTransfersResponse>; | ||
export type ModulesResponse = { | ||
@@ -233,8 +204,3 @@ safes: string[]; | ||
}; | ||
export type SafeMessageListResponse = { | ||
readonly count: number; | ||
readonly next?: string; | ||
readonly previous?: string; | ||
readonly results: SafeMessage[]; | ||
}; | ||
export type SafeMessageListResponse = ListResponse<SafeMessage>; | ||
export type AddMessageProps = { | ||
@@ -247,5 +213,3 @@ message: string | EIP712TypedData; | ||
ordering?: string; | ||
limit?: string; | ||
offset?: string; | ||
}; | ||
} & ListOptions; | ||
export type EIP712TypedData = { | ||
@@ -261,13 +225,4 @@ domain: TypedDataDomain; | ||
ordering?: string; | ||
/** Maximum number of results to return per page */ | ||
limit?: string; | ||
/** Initial index from which to return the results */ | ||
offset?: string; | ||
}; | ||
export type GetSafeOperationListResponse = { | ||
readonly count: number; | ||
readonly next?: string; | ||
readonly previous?: string; | ||
readonly results: Array<SafeOperationResponse>; | ||
}; | ||
} & ListOptions; | ||
export type GetSafeOperationListResponse = ListResponse<SafeOperationResponse>; | ||
export type AddSafeOperationProps = { | ||
@@ -274,0 +229,0 @@ /** Address of the EntryPoint contract */ |
{ | ||
"name": "@safe-global/api-kit", | ||
"version": "2.4.2", | ||
"version": "2.4.3", | ||
"description": "SDK that facilitates the interaction with the Safe Transaction Service API", | ||
@@ -62,4 +62,4 @@ "main": "dist/src/index.js", | ||
"dependencies": { | ||
"@safe-global/protocol-kit": "^4.0.2", | ||
"@safe-global/safe-core-sdk-types": "^5.0.2", | ||
"@safe-global/protocol-kit": "^4.0.3", | ||
"@safe-global/safe-core-sdk-types": "^5.0.3", | ||
"ethers": "^6.13.1", | ||
@@ -66,0 +66,0 @@ "node-fetch": "^2.7.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
174559
1486