@gnosis.pm/safe-react-gateway-sdk
Advanced tools
Comparing version 3.4.6 to 3.5.0
@@ -1,2 +0,3 @@ | ||
import type { paths } from './types/api'; | ||
export declare function callEndpoint<T extends keyof paths>(baseUrl: string, path: T, parameters?: paths[T]['get']['parameters'], rawUrl?: string): Promise<paths[T]['get']['responses'][200]['schema']>; | ||
import type { GetEndpoint, paths, PostEndpoint } from './types/api'; | ||
export declare function postEndpoint<T extends keyof paths>(baseUrl: string, path: T, params?: paths[T] extends PostEndpoint ? paths[T]['post']['parameters'] : never): Promise<paths[T] extends PostEndpoint ? paths[T]['post']['responses'][200]['schema'] : never>; | ||
export declare function getEndpoint<T extends keyof paths>(baseUrl: string, path: T, params?: paths[T] extends GetEndpoint ? paths[T]['get']['parameters'] : never, rawUrl?: string): Promise<paths[T] extends GetEndpoint ? paths[T]['get']['responses'][200]['schema'] : never>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.callEndpoint = void 0; | ||
exports.getEndpoint = exports.postEndpoint = void 0; | ||
const utils_1 = require("./utils"); | ||
function callEndpoint(baseUrl, path, parameters, rawUrl) { | ||
function makeUrl(baseUrl, path, pathParams, query) { | ||
const pathname = (0, utils_1.insertParams)(path, pathParams); | ||
const search = (0, utils_1.stringifyQuery)(query); | ||
return `${baseUrl}${pathname}${search}`; | ||
} | ||
function postEndpoint(baseUrl, path, params) { | ||
const url = makeUrl(baseUrl, path, params === null || params === void 0 ? void 0 : params.path, params === null || params === void 0 ? void 0 : params.query); | ||
return (0, utils_1.fetchData)(url, params === null || params === void 0 ? void 0 : params.body); | ||
} | ||
exports.postEndpoint = postEndpoint; | ||
function getEndpoint(baseUrl, path, params, rawUrl) { | ||
if (rawUrl) { | ||
return (0, utils_1.fetchData)(rawUrl); | ||
} | ||
const params = parameters; | ||
const pathname = (0, utils_1.insertParams)(path, params === null || params === void 0 ? void 0 : params.path); | ||
const search = (0, utils_1.stringifyQuery)(params === null || params === void 0 ? void 0 : params.query); | ||
const url = `${baseUrl}${pathname}${search}`; | ||
return (0, utils_1.fetchData)(url, params === null || params === void 0 ? void 0 : params.body); | ||
const url = makeUrl(baseUrl, path, params === null || params === void 0 ? void 0 : params.path, params === null || params === void 0 ? void 0 : params.query); | ||
return (0, utils_1.fetchData)(url); | ||
} | ||
exports.callEndpoint = callEndpoint; | ||
exports.getEndpoint = getEndpoint; | ||
//# sourceMappingURL=endpoint.js.map |
@@ -9,2 +9,3 @@ import type { operations } from './types/api'; | ||
import type { DecodedDataResponse } from './types/decoded-data'; | ||
import type { SafeMessageListPage } from './types/safe-messages'; | ||
export * from './types/safe-info'; | ||
@@ -17,2 +18,3 @@ export * from './types/safe-apps'; | ||
export * from './types/decoded-data'; | ||
export * from './types/safe-messages'; | ||
/** | ||
@@ -98,1 +100,13 @@ * Set the base CGW URL | ||
export declare function getDecodedData(chainId: string, encodedData: operations['data_decoder']['parameters']['body']['data']): Promise<DecodedDataResponse>; | ||
/** | ||
* Returns list of `SafeMessage`s | ||
*/ | ||
export declare function getSafeMessages(chainId: string, address: string, pageUrl?: string): Promise<SafeMessageListPage>; | ||
/** | ||
* Propose a new `SafeMessage` for other owners to sign | ||
*/ | ||
export declare function proposeSafeMessage(chainId: string, address: string, body: operations['propose_safe_message']['parameters']['body']): Promise<void>; | ||
/** | ||
* Add a confirmation to a `SafeMessage` | ||
*/ | ||
export declare function confirmSafeMessage(chainId: string, messageHash: string, body: operations['confirm_safe_message']['parameters']['body']): Promise<void>; |
@@ -17,3 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getDecodedData = exports.getMasterCopies = exports.getSafeApps = exports.getChainConfig = exports.getChainsConfig = exports.proposeTransaction = exports.postSafeGasEstimation = exports.getTransactionDetails = exports.getTransactionQueue = exports.getTransactionHistory = exports.getCollectiblesPage = exports.getCollectibles = exports.getOwnedSafes = exports.getFiatCurrencies = exports.getBalances = exports.getMultisigTransactions = exports.getModuleTransactions = exports.getIncomingTransfers = exports.getSafeInfo = exports.setBaseUrl = void 0; | ||
exports.confirmSafeMessage = exports.proposeSafeMessage = exports.getSafeMessages = exports.getDecodedData = exports.getMasterCopies = exports.getSafeApps = exports.getChainConfig = exports.getChainsConfig = exports.proposeTransaction = exports.postSafeGasEstimation = exports.getTransactionDetails = exports.getTransactionQueue = exports.getTransactionHistory = exports.getCollectiblesPage = exports.getCollectibles = exports.getOwnedSafes = exports.getFiatCurrencies = exports.getBalances = exports.getMultisigTransactions = exports.getModuleTransactions = exports.getIncomingTransfers = exports.getSafeInfo = exports.setBaseUrl = void 0; | ||
const endpoint_1 = require("./endpoint"); | ||
@@ -28,2 +28,3 @@ const config_1 = require("./config"); | ||
__exportStar(require("./types/decoded-data"), exports); | ||
__exportStar(require("./types/safe-messages"), exports); | ||
// Can be set externally to a different CGW host | ||
@@ -43,3 +44,3 @@ let baseUrl = config_1.DEFAULT_BASE_URL; | ||
function getSafeInfo(chainId, address) { | ||
return (0, endpoint_1.callEndpoint)(baseUrl, '/v1/chains/{chainId}/safes/{address}', { path: { chainId, address } }); | ||
return (0, endpoint_1.getEndpoint)(baseUrl, '/v1/chains/{chainId}/safes/{address}', { path: { chainId, address } }); | ||
} | ||
@@ -51,3 +52,3 @@ exports.getSafeInfo = getSafeInfo; | ||
function getIncomingTransfers(chainId, address, query, pageUrl) { | ||
return (0, endpoint_1.callEndpoint)(baseUrl, '/v1/chains/{chainId}/safes/{address}/incoming-transfers/', { | ||
return (0, endpoint_1.getEndpoint)(baseUrl, '/v1/chains/{chainId}/safes/{address}/incoming-transfers/', { | ||
path: { chainId, address }, | ||
@@ -62,3 +63,3 @@ query, | ||
function getModuleTransactions(chainId, address, query, pageUrl) { | ||
return (0, endpoint_1.callEndpoint)(baseUrl, '/v1/chains/{chainId}/safes/{address}/module-transactions/', { | ||
return (0, endpoint_1.getEndpoint)(baseUrl, '/v1/chains/{chainId}/safes/{address}/module-transactions/', { | ||
path: { chainId, address }, | ||
@@ -73,3 +74,3 @@ query, | ||
function getMultisigTransactions(chainId, address, query, pageUrl) { | ||
return (0, endpoint_1.callEndpoint)(baseUrl, '/v1/chains/{chainId}/safes/{address}/multisig-transactions/', { | ||
return (0, endpoint_1.getEndpoint)(baseUrl, '/v1/chains/{chainId}/safes/{address}/multisig-transactions/', { | ||
path: { chainId, address }, | ||
@@ -84,3 +85,3 @@ query, | ||
function getBalances(chainId, address, currency = 'usd', query = {}) { | ||
return (0, endpoint_1.callEndpoint)(baseUrl, '/v1/chains/{chainId}/safes/{address}/balances/{currency}', { | ||
return (0, endpoint_1.getEndpoint)(baseUrl, '/v1/chains/{chainId}/safes/{address}/balances/{currency}', { | ||
path: { chainId, address, currency }, | ||
@@ -95,3 +96,3 @@ query, | ||
function getFiatCurrencies() { | ||
return (0, endpoint_1.callEndpoint)(baseUrl, '/v1/balances/supported-fiat-codes'); | ||
return (0, endpoint_1.getEndpoint)(baseUrl, '/v1/balances/supported-fiat-codes'); | ||
} | ||
@@ -103,3 +104,3 @@ exports.getFiatCurrencies = getFiatCurrencies; | ||
function getOwnedSafes(chainId, address) { | ||
return (0, endpoint_1.callEndpoint)(baseUrl, '/v1/chains/{chainId}/owners/{address}/safes', { path: { chainId, address } }); | ||
return (0, endpoint_1.getEndpoint)(baseUrl, '/v1/chains/{chainId}/owners/{address}/safes', { path: { chainId, address } }); | ||
} | ||
@@ -111,3 +112,3 @@ exports.getOwnedSafes = getOwnedSafes; | ||
function getCollectibles(chainId, address, query = {}) { | ||
return (0, endpoint_1.callEndpoint)(baseUrl, '/v1/chains/{chainId}/safes/{address}/collectibles', { | ||
return (0, endpoint_1.getEndpoint)(baseUrl, '/v1/chains/{chainId}/safes/{address}/collectibles', { | ||
path: { chainId, address }, | ||
@@ -122,3 +123,3 @@ query, | ||
function getCollectiblesPage(chainId, address, query = {}, pageUrl) { | ||
return (0, endpoint_1.callEndpoint)(baseUrl, '/v2/chains/{chainId}/safes/{address}/collectibles', { path: { chainId, address }, query }, pageUrl); | ||
return (0, endpoint_1.getEndpoint)(baseUrl, '/v2/chains/{chainId}/safes/{address}/collectibles', { path: { chainId, address }, query }, pageUrl); | ||
} | ||
@@ -130,3 +131,3 @@ exports.getCollectiblesPage = getCollectiblesPage; | ||
function getTransactionHistory(chainId, address, pageUrl) { | ||
return (0, endpoint_1.callEndpoint)(baseUrl, '/v1/chains/{chainId}/safes/{safe_address}/transactions/history', { path: { chainId, safe_address: address }, query: {} }, pageUrl); | ||
return (0, endpoint_1.getEndpoint)(baseUrl, '/v1/chains/{chainId}/safes/{safe_address}/transactions/history', { path: { chainId, safe_address: address }, query: {} }, pageUrl); | ||
} | ||
@@ -138,3 +139,3 @@ exports.getTransactionHistory = getTransactionHistory; | ||
function getTransactionQueue(chainId, address, pageUrl, trusted) { | ||
return (0, endpoint_1.callEndpoint)(baseUrl, '/v1/chains/{chainId}/safes/{safe_address}/transactions/queued', { path: { chainId, safe_address: address }, query: { trusted } }, pageUrl); | ||
return (0, endpoint_1.getEndpoint)(baseUrl, '/v1/chains/{chainId}/safes/{safe_address}/transactions/queued', { path: { chainId, safe_address: address }, query: { trusted } }, pageUrl); | ||
} | ||
@@ -146,3 +147,3 @@ exports.getTransactionQueue = getTransactionQueue; | ||
function getTransactionDetails(chainId, transactionId) { | ||
return (0, endpoint_1.callEndpoint)(baseUrl, '/v1/chains/{chainId}/transactions/{transactionId}', { | ||
return (0, endpoint_1.getEndpoint)(baseUrl, '/v1/chains/{chainId}/transactions/{transactionId}', { | ||
path: { chainId, transactionId }, | ||
@@ -156,3 +157,3 @@ }); | ||
function postSafeGasEstimation(chainId, address, body) { | ||
return (0, endpoint_1.callEndpoint)(baseUrl, '/v2/chains/{chainId}/safes/{safe_address}/multisig-transactions/estimations', { | ||
return (0, endpoint_1.postEndpoint)(baseUrl, '/v2/chains/{chainId}/safes/{safe_address}/multisig-transactions/estimations', { | ||
path: { chainId, safe_address: address }, | ||
@@ -167,3 +168,3 @@ body, | ||
function proposeTransaction(chainId, address, body) { | ||
return (0, endpoint_1.callEndpoint)(baseUrl, '/v1/chains/{chainId}/transactions/{safe_address}/propose', { | ||
return (0, endpoint_1.postEndpoint)(baseUrl, '/v1/chains/{chainId}/transactions/{safe_address}/propose', { | ||
path: { chainId, safe_address: address }, | ||
@@ -178,3 +179,3 @@ body, | ||
function getChainsConfig(query) { | ||
return (0, endpoint_1.callEndpoint)(baseUrl, '/v1/chains', { | ||
return (0, endpoint_1.getEndpoint)(baseUrl, '/v1/chains', { | ||
query, | ||
@@ -188,3 +189,3 @@ }); | ||
function getChainConfig(chainId) { | ||
return (0, endpoint_1.callEndpoint)(baseUrl, '/v1/chains/{chainId}', { | ||
return (0, endpoint_1.getEndpoint)(baseUrl, '/v1/chains/{chainId}', { | ||
path: { chainId: chainId }, | ||
@@ -198,3 +199,3 @@ }); | ||
function getSafeApps(chainId, query = {}) { | ||
return (0, endpoint_1.callEndpoint)(baseUrl, '/v1/chains/{chainId}/safe-apps', { | ||
return (0, endpoint_1.getEndpoint)(baseUrl, '/v1/chains/{chainId}/safe-apps', { | ||
path: { chainId: chainId }, | ||
@@ -209,3 +210,3 @@ query, | ||
function getMasterCopies(chainId) { | ||
return (0, endpoint_1.callEndpoint)(baseUrl, '/v1/chains/{chainId}/about/master-copies', { | ||
return (0, endpoint_1.getEndpoint)(baseUrl, '/v1/chains/{chainId}/about/master-copies', { | ||
path: { chainId: chainId }, | ||
@@ -219,3 +220,3 @@ }); | ||
function getDecodedData(chainId, encodedData) { | ||
return (0, endpoint_1.callEndpoint)(baseUrl, '/v1/chains/{chainId}/data-decoder', { | ||
return (0, endpoint_1.postEndpoint)(baseUrl, '/v1/chains/{chainId}/data-decoder', { | ||
path: { chainId: chainId }, | ||
@@ -226,3 +227,30 @@ body: { data: encodedData }, | ||
exports.getDecodedData = getDecodedData; | ||
/** | ||
* Returns list of `SafeMessage`s | ||
*/ | ||
function getSafeMessages(chainId, address, pageUrl) { | ||
return (0, endpoint_1.getEndpoint)(baseUrl, '/v1/chains/{chainId}/safes/{safe_address}/messages', { path: { chainId, safe_address: address }, query: {} }, pageUrl); | ||
} | ||
exports.getSafeMessages = getSafeMessages; | ||
/** | ||
* Propose a new `SafeMessage` for other owners to sign | ||
*/ | ||
function proposeSafeMessage(chainId, address, body) { | ||
return (0, endpoint_1.postEndpoint)(baseUrl, '/v1/chains/{chainId}/safes/{safe_address}/messages', { | ||
path: { chainId, safe_address: address }, | ||
body, | ||
}); | ||
} | ||
exports.proposeSafeMessage = proposeSafeMessage; | ||
/** | ||
* Add a confirmation to a `SafeMessage` | ||
*/ | ||
function confirmSafeMessage(chainId, messageHash, body) { | ||
return (0, endpoint_1.postEndpoint)(baseUrl, '/v1/chains/{chainId}/messages/{message_hash}/signatures', { | ||
path: { chainId, message_hash: messageHash }, | ||
body, | ||
}); | ||
} | ||
exports.confirmSafeMessage = confirmSafeMessage; | ||
/* eslint-enable @typescript-eslint/explicit-module-boundary-types */ | ||
//# sourceMappingURL=index.js.map |
@@ -8,3 +8,44 @@ import type { FiatCurrencies, OwnedSafes, SafeBalanceResponse, SafeCollectibleResponse, SafeCollectiblesPage } from './common'; | ||
import type { MasterCopyReponse } from './master-copies'; | ||
export interface paths { | ||
import type { ConfirmSafeMessageRequest, ProposeSafeMessageRequest, SafeMessageListPage } from './safe-messages'; | ||
export declare type Primitive = string | number | boolean | null; | ||
interface GetParams { | ||
path?: { | ||
[key: string]: Primitive; | ||
}; | ||
query?: { | ||
[key: string]: Primitive; | ||
}; | ||
} | ||
interface PostParams extends GetParams { | ||
body: string | Record<string, unknown>; | ||
} | ||
interface Responses { | ||
200: { | ||
schema: unknown; | ||
}; | ||
[key: number]: { | ||
schema: unknown; | ||
} | unknown; | ||
} | ||
interface Endpoint { | ||
parameters: { | ||
path: Record<string, Primitive>; | ||
} | null; | ||
} | ||
export interface GetEndpoint extends Endpoint { | ||
get: { | ||
parameters: GetParams | null; | ||
responses: Responses; | ||
}; | ||
} | ||
export interface PostEndpoint extends Endpoint { | ||
post: { | ||
parameters: PostParams | null; | ||
responses: Responses; | ||
}; | ||
} | ||
interface PathRegistry { | ||
[key: string]: GetEndpoint | PostEndpoint | (GetEndpoint & PostEndpoint); | ||
} | ||
export interface paths extends PathRegistry { | ||
'/v1/chains/{chainId}/safes/{address}': { | ||
@@ -112,4 +153,3 @@ /** Get status of the safe */ | ||
'/v2/chains/{chainId}/safes/{safe_address}/multisig-transactions/estimations': { | ||
/** This is actually supposed to be POST but it breaks our type paradise */ | ||
get: operations['post_safe_gas_estimation']; | ||
post: operations['post_safe_gas_estimation']; | ||
parameters: { | ||
@@ -123,4 +163,3 @@ path: { | ||
'/v1/chains/{chainId}/transactions/{safe_address}/propose': { | ||
/** This is actually supposed to be POST but it breaks our type paradise */ | ||
get: operations['propose_transaction']; | ||
post: operations['propose_transaction']; | ||
parameters: { | ||
@@ -144,9 +183,3 @@ path: { | ||
get: operations['chains_list']; | ||
parameters: { | ||
query: { | ||
ordering?: string; | ||
limit?: number; | ||
offset?: number; | ||
}; | ||
}; | ||
parameters: null; | ||
}; | ||
@@ -178,3 +211,3 @@ '/v1/chains/{chainId}': { | ||
'/v1/chains/{chainId}/data-decoder': { | ||
get: operations['data_decoder']; | ||
post: operations['data_decoder']; | ||
parameters: { | ||
@@ -186,2 +219,21 @@ path: { | ||
}; | ||
'/v1/chains/{chainId}/safes/{safe_address}/messages': { | ||
get: operations['get_safe_messages']; | ||
post: operations['propose_safe_message']; | ||
parameters: { | ||
path: { | ||
chainId: string; | ||
safe_address: string; | ||
}; | ||
}; | ||
}; | ||
'/v1/chains/{chainId}/messages/{message_hash}/signatures': { | ||
post: operations['confirm_safe_message']; | ||
parameters: { | ||
path: { | ||
chainId: string; | ||
message_hash: string; | ||
}; | ||
}; | ||
}; | ||
} | ||
@@ -534,2 +586,48 @@ export interface operations { | ||
}; | ||
get_safe_messages: { | ||
parameters: { | ||
path: { | ||
chainId: string; | ||
safe_address: string; | ||
}; | ||
query: { | ||
/** Taken from the Page['next'] or Page['previous'] */ | ||
page_url?: string; | ||
}; | ||
}; | ||
responses: { | ||
200: { | ||
schema: SafeMessageListPage; | ||
}; | ||
}; | ||
}; | ||
propose_safe_message: { | ||
parameters: { | ||
path: { | ||
chainId: string; | ||
safe_address: string; | ||
}; | ||
body: ProposeSafeMessageRequest; | ||
}; | ||
responses: { | ||
200: { | ||
schema: void; | ||
}; | ||
}; | ||
}; | ||
confirm_safe_message: { | ||
parameters: { | ||
path: { | ||
chainId: string; | ||
message_hash: string; | ||
}; | ||
body: ConfirmSafeMessageRequest; | ||
}; | ||
responses: { | ||
200: { | ||
schema: void; | ||
}; | ||
}; | ||
}; | ||
} | ||
export {}; |
{ | ||
"name": "@gnosis.pm/safe-react-gateway-sdk", | ||
"version": "3.4.6", | ||
"version": "3.5.0", | ||
"main": "dist/index.js", | ||
@@ -30,3 +30,3 @@ "types": "dist/index.d.ts", | ||
"scripts": { | ||
"lint": "eslint './src/**/*.ts'", | ||
"lint": "tsc && eslint './src/**/*.ts'", | ||
"lint:fix": "yarn lint --fix", | ||
@@ -33,0 +33,0 @@ "build": "rm -rf dist && tsc", |
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
77939
42
1826