@0xsequence/indexer
Advanced tools
Comparing version 2.1.8 to 2.2.0
@@ -23,9 +23,9 @@ 'use strict'; | ||
// WebRPC description and code-gen version | ||
const WebRPCVersion = 'v1'; | ||
const WebRPCVersion$1 = 'v1'; | ||
// Schema version of your RIDL schema | ||
const WebRPCSchemaVersion = 'v0.4.0'; | ||
const WebRPCSchemaVersion$1 = 'v0.4.0'; | ||
// Schema hash generated from your RIDL schema | ||
const WebRPCSchemaHash = 'cae735346d8e5c3dce48dce9f85116989b6beffd'; | ||
const WebRPCSchemaHash$1 = 'cae735346d8e5c3dce48dce9f85116989b6beffd'; | ||
@@ -36,3 +36,3 @@ // | ||
let ContractType = /*#__PURE__*/function (ContractType) { | ||
let ContractType$1 = /*#__PURE__*/function (ContractType) { | ||
ContractType["UNKNOWN"] = "UNKNOWN"; | ||
@@ -50,3 +50,3 @@ ContractType["NATIVE"] = "NATIVE"; | ||
}({}); | ||
let EventLogType = /*#__PURE__*/function (EventLogType) { | ||
let EventLogType$1 = /*#__PURE__*/function (EventLogType) { | ||
EventLogType["UNKNOWN"] = "UNKNOWN"; | ||
@@ -57,3 +57,3 @@ EventLogType["BLOCK_ADDED"] = "BLOCK_ADDED"; | ||
}({}); | ||
let EventLogDataType = /*#__PURE__*/function (EventLogDataType) { | ||
let EventLogDataType$1 = /*#__PURE__*/function (EventLogDataType) { | ||
EventLogDataType["EVENT"] = "EVENT"; | ||
@@ -65,3 +65,3 @@ EventLogDataType["TOKEN_TRANSFER"] = "TOKEN_TRANSFER"; | ||
}({}); | ||
let OrderStatus = /*#__PURE__*/function (OrderStatus) { | ||
let OrderStatus$1 = /*#__PURE__*/function (OrderStatus) { | ||
OrderStatus["OPEN"] = "OPEN"; | ||
@@ -72,3 +72,3 @@ OrderStatus["CLOSED"] = "CLOSED"; | ||
}({}); | ||
let TxnTransferType = /*#__PURE__*/function (TxnTransferType) { | ||
let TxnTransferType$1 = /*#__PURE__*/function (TxnTransferType) { | ||
TxnTransferType["UNKNOWN"] = "UNKNOWN"; | ||
@@ -79,3 +79,3 @@ TxnTransferType["SEND"] = "SEND"; | ||
}({}); | ||
let TransactionStatus = /*#__PURE__*/function (TransactionStatus) { | ||
let TransactionStatus$1 = /*#__PURE__*/function (TransactionStatus) { | ||
TransactionStatus["FAILED"] = "FAILED"; | ||
@@ -85,3 +85,3 @@ TransactionStatus["SUCCESSFUL"] = "SUCCESSFUL"; | ||
}({}); | ||
let TransactionType = /*#__PURE__*/function (TransactionType) { | ||
let TransactionType$1 = /*#__PURE__*/function (TransactionType) { | ||
TransactionType["LegacyTxnType"] = "LegacyTxnType"; | ||
@@ -92,3 +92,3 @@ TransactionType["AccessListTxnType"] = "AccessListTxnType"; | ||
}({}); | ||
let SortOrder = /*#__PURE__*/function (SortOrder) { | ||
let SortOrder$1 = /*#__PURE__*/function (SortOrder) { | ||
SortOrder["DESC"] = "DESC"; | ||
@@ -98,3 +98,3 @@ SortOrder["ASC"] = "ASC"; | ||
}({}); | ||
let ContractVerificationStatus = /*#__PURE__*/function (ContractVerificationStatus) { | ||
let ContractVerificationStatus$1 = /*#__PURE__*/function (ContractVerificationStatus) { | ||
ContractVerificationStatus["VERIFIED"] = "VERIFIED"; | ||
@@ -114,4 +114,4 @@ ContractVerificationStatus["UNVERIFIED"] = "UNVERIFIED"; | ||
this.ping = (headers, signal) => { | ||
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('Ping'), createHTTPRequest$1({}, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -122,3 +122,3 @@ status: _data.status | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -129,4 +129,4 @@ }); | ||
this.version = (headers, signal) => { | ||
return this.fetch(this.url('Version'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('Version'), createHTTPRequest$1({}, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -137,3 +137,3 @@ version: _data.version | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -144,4 +144,4 @@ }); | ||
this.runtimeStatus = (headers, signal) => { | ||
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest$1({}, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -152,3 +152,3 @@ status: _data.status | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -159,4 +159,4 @@ }); | ||
this.getChainID = (headers, signal) => { | ||
return this.fetch(this.url('GetChainID'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetChainID'), createHTTPRequest$1({}, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -167,3 +167,3 @@ chainID: _data.chainID | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -174,4 +174,4 @@ }); | ||
this.getEtherBalance = (args, headers, signal) => { | ||
return this.fetch(this.url('GetEtherBalance'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetEtherBalance'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -182,3 +182,3 @@ balance: _data.balance | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -189,4 +189,4 @@ }); | ||
this.getNativeTokenBalance = (args, headers, signal) => { | ||
return this.fetch(this.url('GetNativeTokenBalance'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetNativeTokenBalance'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -197,3 +197,3 @@ balance: _data.balance | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -204,4 +204,4 @@ }); | ||
this.getTokenBalancesSummary = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalancesSummary'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTokenBalancesSummary'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -213,3 +213,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -220,4 +220,4 @@ }); | ||
this.getTokenBalancesDetails = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalancesDetails'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTokenBalancesDetails'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -229,3 +229,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -236,4 +236,4 @@ }); | ||
this.getTokenBalancesByContract = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalancesByContract'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTokenBalancesByContract'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -245,3 +245,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -252,4 +252,4 @@ }); | ||
this.getTokenBalances = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalances'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTokenBalances'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -261,3 +261,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -268,4 +268,4 @@ }); | ||
this.getTokenSupplies = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenSupplies'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTokenSupplies'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -278,3 +278,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -285,4 +285,4 @@ }); | ||
this.getTokenSuppliesMap = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenSuppliesMap'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTokenSuppliesMap'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -293,3 +293,3 @@ supplies: _data.supplies | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -300,4 +300,4 @@ }); | ||
this.getBalanceUpdates = (args, headers, signal) => { | ||
return this.fetch(this.url('GetBalanceUpdates'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetBalanceUpdates'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -309,3 +309,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -316,4 +316,4 @@ }); | ||
this.getTransactionHistory = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTransactionHistory'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTransactionHistory'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -325,3 +325,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -332,8 +332,8 @@ }); | ||
this.syncBalance = (args, headers, signal) => { | ||
return this.fetch(this.url('SyncBalance'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('SyncBalance'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return {}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -344,4 +344,4 @@ }); | ||
this.fetchTransactionReceipt = (args, headers, signal) => { | ||
return this.fetch(this.url('FetchTransactionReceipt'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('FetchTransactionReceipt'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -352,3 +352,3 @@ receipt: _data.receipt | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -359,4 +359,4 @@ }); | ||
this.getOrderbookOrders = (args, headers, signal) => { | ||
return this.fetch(this.url('GetOrderbookOrders'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetOrderbookOrders'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -368,3 +368,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -375,4 +375,4 @@ }); | ||
this.getTopOrders = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTopOrders'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTopOrders'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -383,3 +383,3 @@ orders: _data.orders | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -390,4 +390,4 @@ }); | ||
this.fetchTransactionReceiptWithFilter = (args, headers, signal) => { | ||
return this.fetch(this.url('FetchTransactionReceiptWithFilter'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('FetchTransactionReceiptWithFilter'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -398,3 +398,3 @@ receipt: _data.receipt | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -405,4 +405,4 @@ }); | ||
this.getAllWebhookListeners = (args, headers, signal) => { | ||
return this.fetch(this.url('GetAllWebhookListeners'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetAllWebhookListeners'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -413,3 +413,3 @@ listeners: _data.listeners | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -420,4 +420,4 @@ }); | ||
this.getWebhookListener = (args, headers, signal) => { | ||
return this.fetch(this.url('GetWebhookListener'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -428,3 +428,3 @@ listener: _data.listener | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -435,4 +435,4 @@ }); | ||
this.addWebhookListener = (args, headers, signal) => { | ||
return this.fetch(this.url('AddWebhookListener'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('AddWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -444,3 +444,3 @@ status: _data.status, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -451,4 +451,4 @@ }); | ||
this.updateWebhookListener = (args, headers, signal) => { | ||
return this.fetch(this.url('UpdateWebhookListener'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('UpdateWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -459,3 +459,3 @@ status: _data.status | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -466,4 +466,4 @@ }); | ||
this.removeWebhookListener = (args, headers, signal) => { | ||
return this.fetch(this.url('RemoveWebhookListener'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('RemoveWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -474,3 +474,3 @@ status: _data.status | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -481,4 +481,4 @@ }); | ||
this.toggleWebhookListener = (args, headers, signal) => { | ||
return this.fetch(this.url('ToggleWebhookListener'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('ToggleWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -489,3 +489,3 @@ webhookListener: _data.webhookListener | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -496,4 +496,4 @@ }); | ||
this.pauseAllWebhookListeners = (args, headers, signal) => { | ||
return this.fetch(this.url('PauseAllWebhookListeners'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('PauseAllWebhookListeners'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -504,3 +504,3 @@ status: _data.status | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -511,4 +511,4 @@ }); | ||
this.resumeAllWebhookListeners = (args, headers, signal) => { | ||
return this.fetch(this.url('ResumeAllWebhookListeners'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('ResumeAllWebhookListeners'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -519,3 +519,3 @@ status: _data.status | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -526,3 +526,3 @@ }); | ||
this.subscribeReceipts = (args, options) => { | ||
const _fetch = () => this.fetch(this.url('SubscribeReceipts'), createHTTPRequest(args, options.headers, options.signal)).then(async function (res) { | ||
const _fetch = () => this.fetch(this.url('SubscribeReceipts'), createHTTPRequest$1(args, options.headers, options.signal)).then(async function (res) { | ||
await sseResponse(res, options, _fetch); | ||
@@ -535,3 +535,3 @@ }, error => { | ||
this.subscribeEvents = (args, options) => { | ||
const _fetch = () => this.fetch(this.url('SubscribeEvents'), createHTTPRequest(args, options.headers, options.signal)).then(async function (res) { | ||
const _fetch = () => this.fetch(this.url('SubscribeEvents'), createHTTPRequest$1(args, options.headers, options.signal)).then(async function (res) { | ||
await sseResponse(res, options, _fetch); | ||
@@ -544,3 +544,3 @@ }, error => { | ||
this.subscribeBalanceUpdates = (args, options) => { | ||
const _fetch = () => this.fetch(this.url('SubscribeBalanceUpdates'), createHTTPRequest(args, options.headers, options.signal)).then(async function (res) { | ||
const _fetch = () => this.fetch(this.url('SubscribeBalanceUpdates'), createHTTPRequest$1(args, options.headers, options.signal)).then(async function (res) { | ||
await sseResponse(res, options, _fetch); | ||
@@ -568,3 +568,3 @@ }, error => { | ||
try { | ||
await buildResponse(res); | ||
await buildResponse$1(res); | ||
} catch (error) { | ||
@@ -577,3 +577,3 @@ // @ts-ignore | ||
if (!res.body) { | ||
onError(WebrpcBadResponseError.new({ | ||
onError(WebrpcBadResponseError$1.new({ | ||
status: res.status, | ||
@@ -618,3 +618,3 @@ cause: 'Invalid response, missing body' | ||
if (error instanceof DOMException && error.name === 'AbortError') { | ||
onError(WebrpcRequestFailedError.new({ | ||
onError(WebrpcRequestFailedError$1.new({ | ||
message: 'AbortError', | ||
@@ -626,3 +626,3 @@ cause: `AbortError: ${message}` | ||
} else { | ||
onError(WebrpcStreamLostError.new({ | ||
onError(WebrpcStreamLostError$1.new({ | ||
cause: `reader.read(): ${message}` | ||
@@ -644,3 +644,3 @@ }), retryFetch); | ||
const code = typeof error.code === 'number' ? error.code : 0; | ||
onError((webrpcErrorByCode[code] || WebrpcError).new(error), retryFetch); | ||
onError((webrpcErrorByCode$1[code] || WebrpcError$1).new(error), retryFetch); | ||
return; | ||
@@ -652,3 +652,3 @@ } | ||
} | ||
onError(WebrpcBadResponseError.new({ | ||
onError(WebrpcBadResponseError$1.new({ | ||
status: res.status, | ||
@@ -669,3 +669,3 @@ // @ts-ignore | ||
}; | ||
const createHTTPRequest = (body = {}, headers = {}, signal = null) => { | ||
const createHTTPRequest$1 = (body = {}, headers = {}, signal = null) => { | ||
return { | ||
@@ -680,2 +680,530 @@ method: 'POST', | ||
}; | ||
const buildResponse$1 = res => { | ||
return res.text().then(text => { | ||
let data; | ||
try { | ||
data = JSON.parse(text); | ||
} catch (error) { | ||
let message = ''; | ||
if (error instanceof Error) { | ||
message = error.message; | ||
} | ||
throw WebrpcBadResponseError$1.new({ | ||
status: res.status, | ||
cause: `JSON.parse(): ${message}: response text: ${text}` | ||
}); | ||
} | ||
if (!res.ok) { | ||
const code = typeof data.code === 'number' ? data.code : 0; | ||
throw (webrpcErrorByCode$1[code] || WebrpcError$1).new(data); | ||
} | ||
return data; | ||
}); | ||
}; | ||
// | ||
// Errors | ||
// | ||
class WebrpcError$1 extends Error { | ||
constructor(name, code, message, status, cause) { | ||
super(message); | ||
this.name = void 0; | ||
this.code = void 0; | ||
this.message = void 0; | ||
this.status = void 0; | ||
this.cause = void 0; | ||
/** @deprecated Use message instead of msg. Deprecated in webrpc v0.11.0. */ | ||
this.msg = void 0; | ||
this.name = name || 'WebrpcError'; | ||
this.code = typeof code === 'number' ? code : 0; | ||
this.message = message || `endpoint error ${this.code}`; | ||
this.msg = this.message; | ||
this.status = typeof status === 'number' ? status : 0; | ||
this.cause = cause; | ||
Object.setPrototypeOf(this, WebrpcError$1.prototype); | ||
} | ||
static new(payload) { | ||
return new this(payload.error, payload.code, payload.message || payload.msg, payload.status, payload.cause); | ||
} | ||
} | ||
// Webrpc errors | ||
class WebrpcEndpointError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcEndpoint', code = 0, message = 'endpoint error', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcEndpointError$1.prototype); | ||
} | ||
} | ||
class WebrpcRequestFailedError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcRequestFailed', code = -1, message = 'request failed', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcRequestFailedError$1.prototype); | ||
} | ||
} | ||
class WebrpcBadRouteError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcBadRoute', code = -2, message = 'bad route', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcBadRouteError$1.prototype); | ||
} | ||
} | ||
class WebrpcBadMethodError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcBadMethod', code = -3, message = 'bad method', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcBadMethodError$1.prototype); | ||
} | ||
} | ||
class WebrpcBadRequestError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcBadRequest', code = -4, message = 'bad request', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcBadRequestError$1.prototype); | ||
} | ||
} | ||
class WebrpcBadResponseError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcBadResponse', code = -5, message = 'bad response', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcBadResponseError$1.prototype); | ||
} | ||
} | ||
class WebrpcServerPanicError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcServerPanic', code = -6, message = 'server panic', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcServerPanicError$1.prototype); | ||
} | ||
} | ||
class WebrpcInternalErrorError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcInternalError', code = -7, message = 'internal error', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcInternalErrorError$1.prototype); | ||
} | ||
} | ||
class WebrpcClientDisconnectedError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcClientDisconnected', code = -8, message = 'client disconnected', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcClientDisconnectedError$1.prototype); | ||
} | ||
} | ||
class WebrpcStreamLostError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcStreamLost', code = -9, message = 'stream lost', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcStreamLostError$1.prototype); | ||
} | ||
} | ||
class WebrpcStreamFinishedError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcStreamFinished', code = -10, message = 'stream finished', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcStreamFinishedError$1.prototype); | ||
} | ||
} | ||
// Schema errors | ||
class UnauthorizedError$1 extends WebrpcError$1 { | ||
constructor(name = 'Unauthorized', code = 1000, message = 'Unauthorized access', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, UnauthorizedError$1.prototype); | ||
} | ||
} | ||
class PermissionDeniedError$1 extends WebrpcError$1 { | ||
constructor(name = 'PermissionDenied', code = 1001, message = 'Permission denied', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, PermissionDeniedError$1.prototype); | ||
} | ||
} | ||
class SessionExpiredError$1 extends WebrpcError$1 { | ||
constructor(name = 'SessionExpired', code = 1002, message = 'Session expired', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, SessionExpiredError$1.prototype); | ||
} | ||
} | ||
class MethodNotFoundError$1 extends WebrpcError$1 { | ||
constructor(name = 'MethodNotFound', code = 1003, message = 'Method not found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, MethodNotFoundError$1.prototype); | ||
} | ||
} | ||
class RequestConflictError$1 extends WebrpcError$1 { | ||
constructor(name = 'RequestConflict', code = 1004, message = 'Conflict with target resource', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, RequestConflictError$1.prototype); | ||
} | ||
} | ||
class AbortedError$1 extends WebrpcError$1 { | ||
constructor(name = 'Aborted', code = 1005, message = 'Request aborted', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, AbortedError$1.prototype); | ||
} | ||
} | ||
class TimeoutError$1 extends WebrpcError$1 { | ||
constructor(name = 'Timeout', code = 2000, message = 'Request timed out', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, TimeoutError$1.prototype); | ||
} | ||
} | ||
class InvalidArgumentError$1 extends WebrpcError$1 { | ||
constructor(name = 'InvalidArgument', code = 2001, message = 'Invalid argument', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, InvalidArgumentError$1.prototype); | ||
} | ||
} | ||
class UnavailableError$1 extends WebrpcError$1 { | ||
constructor(name = 'Unavailable', code = 2002, message = 'Unavailable resource', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, UnavailableError$1.prototype); | ||
} | ||
} | ||
class QueryFailedError$1 extends WebrpcError$1 { | ||
constructor(name = 'QueryFailed', code = 2003, message = 'Query failed', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, QueryFailedError$1.prototype); | ||
} | ||
} | ||
class ResourceExhaustedError$1 extends WebrpcError$1 { | ||
constructor(name = 'ResourceExhausted', code = 2004, message = 'Resource exhausted', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, ResourceExhaustedError$1.prototype); | ||
} | ||
} | ||
class NotFoundError$1 extends WebrpcError$1 { | ||
constructor(name = 'NotFound', code = 3000, message = 'Resource not found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, NotFoundError$1.prototype); | ||
} | ||
} | ||
class ProjectNotFoundError$1 extends WebrpcError$1 { | ||
constructor(name = 'ProjectNotFound', code = 3002, message = 'Project not found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, ProjectNotFoundError$1.prototype); | ||
} | ||
} | ||
class MetadataCallFailedError$1 extends WebrpcError$1 { | ||
constructor(name = 'MetadataCallFailed', code = 3003, message = 'Metadata service call failed', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, MetadataCallFailedError$1.prototype); | ||
} | ||
} | ||
let errors$1 = /*#__PURE__*/function (errors) { | ||
errors["WebrpcEndpoint"] = "WebrpcEndpoint"; | ||
errors["WebrpcRequestFailed"] = "WebrpcRequestFailed"; | ||
errors["WebrpcBadRoute"] = "WebrpcBadRoute"; | ||
errors["WebrpcBadMethod"] = "WebrpcBadMethod"; | ||
errors["WebrpcBadRequest"] = "WebrpcBadRequest"; | ||
errors["WebrpcBadResponse"] = "WebrpcBadResponse"; | ||
errors["WebrpcServerPanic"] = "WebrpcServerPanic"; | ||
errors["WebrpcInternalError"] = "WebrpcInternalError"; | ||
errors["WebrpcClientDisconnected"] = "WebrpcClientDisconnected"; | ||
errors["WebrpcStreamLost"] = "WebrpcStreamLost"; | ||
errors["WebrpcStreamFinished"] = "WebrpcStreamFinished"; | ||
errors["Unauthorized"] = "Unauthorized"; | ||
errors["PermissionDenied"] = "PermissionDenied"; | ||
errors["SessionExpired"] = "SessionExpired"; | ||
errors["MethodNotFound"] = "MethodNotFound"; | ||
errors["RequestConflict"] = "RequestConflict"; | ||
errors["Aborted"] = "Aborted"; | ||
errors["Timeout"] = "Timeout"; | ||
errors["InvalidArgument"] = "InvalidArgument"; | ||
errors["Unavailable"] = "Unavailable"; | ||
errors["QueryFailed"] = "QueryFailed"; | ||
errors["ResourceExhausted"] = "ResourceExhausted"; | ||
errors["NotFound"] = "NotFound"; | ||
errors["ProjectNotFound"] = "ProjectNotFound"; | ||
errors["MetadataCallFailed"] = "MetadataCallFailed"; | ||
return errors; | ||
}({}); | ||
const webrpcErrorByCode$1 = { | ||
[0]: WebrpcEndpointError$1, | ||
[-1]: WebrpcRequestFailedError$1, | ||
[-2]: WebrpcBadRouteError$1, | ||
[-3]: WebrpcBadMethodError$1, | ||
[-4]: WebrpcBadRequestError$1, | ||
[-5]: WebrpcBadResponseError$1, | ||
[-6]: WebrpcServerPanicError$1, | ||
[-7]: WebrpcInternalErrorError$1, | ||
[-8]: WebrpcClientDisconnectedError$1, | ||
[-9]: WebrpcStreamLostError$1, | ||
[-10]: WebrpcStreamFinishedError$1, | ||
[1000]: UnauthorizedError$1, | ||
[1001]: PermissionDeniedError$1, | ||
[1002]: SessionExpiredError$1, | ||
[1003]: MethodNotFoundError$1, | ||
[1004]: RequestConflictError$1, | ||
[1005]: AbortedError$1, | ||
[2000]: TimeoutError$1, | ||
[2001]: InvalidArgumentError$1, | ||
[2002]: UnavailableError$1, | ||
[2003]: QueryFailedError$1, | ||
[2004]: ResourceExhaustedError$1, | ||
[3000]: NotFoundError$1, | ||
[3002]: ProjectNotFoundError$1, | ||
[3003]: MetadataCallFailedError$1 | ||
}; | ||
/* eslint-disable */ | ||
// sequence-indexer v0.4.0 71cd081c5ca2372bf92a897ae1aa4ebf93ffd0fc | ||
// -- | ||
// Code generated by webrpc-gen@v0.21.1 with typescript generator. DO NOT EDIT. | ||
// | ||
// webrpc-gen -schema=indexer.ridl -service=IndexerGateway -target=typescript -client -out=./clients/indexergw/indexer.gen.ts | ||
const WebrpcHeader = "Webrpc"; | ||
const WebrpcHeaderValue = "webrpc@v0.21.1;gen-typescript@v0.15.1;sequence-indexer@v0.4.0"; | ||
// WebRPC description and code-gen version | ||
const WebRPCVersion = "v1"; | ||
// Schema version of your RIDL schema | ||
const WebRPCSchemaVersion = "v0.4.0"; | ||
// Schema hash generated from your RIDL schema | ||
const WebRPCSchemaHash = "71cd081c5ca2372bf92a897ae1aa4ebf93ffd0fc"; | ||
function VersionFromHeader(headers) { | ||
const headerValue = headers.get(WebrpcHeader); | ||
if (!headerValue) { | ||
return { | ||
webrpcGenVersion: "", | ||
codeGenName: "", | ||
codeGenVersion: "", | ||
schemaName: "", | ||
schemaVersion: "" | ||
}; | ||
} | ||
return parseWebrpcGenVersions(headerValue); | ||
} | ||
function parseWebrpcGenVersions(header) { | ||
const versions = header.split(";"); | ||
if (versions.length < 3) { | ||
return { | ||
webrpcGenVersion: "", | ||
codeGenName: "", | ||
codeGenVersion: "", | ||
schemaName: "", | ||
schemaVersion: "" | ||
}; | ||
} | ||
const [_, webrpcGenVersion] = versions[0].split("@"); | ||
const [codeGenName, codeGenVersion] = versions[1].split("@"); | ||
const [schemaName, schemaVersion] = versions[2].split("@"); | ||
return { | ||
webrpcGenVersion, | ||
codeGenName, | ||
codeGenVersion, | ||
schemaName, | ||
schemaVersion | ||
}; | ||
} | ||
// | ||
// Types | ||
// | ||
let ContractType = /*#__PURE__*/function (ContractType) { | ||
ContractType["UNKNOWN"] = "UNKNOWN"; | ||
ContractType["NATIVE"] = "NATIVE"; | ||
ContractType["ERC20"] = "ERC20"; | ||
ContractType["ERC721"] = "ERC721"; | ||
ContractType["ERC1155"] = "ERC1155"; | ||
ContractType["SEQUENCE_WALLET"] = "SEQUENCE_WALLET"; | ||
ContractType["ERC20_BRIDGE"] = "ERC20_BRIDGE"; | ||
ContractType["ERC721_BRIDGE"] = "ERC721_BRIDGE"; | ||
ContractType["ERC1155_BRIDGE"] = "ERC1155_BRIDGE"; | ||
ContractType["SEQ_MARKETPLACE"] = "SEQ_MARKETPLACE"; | ||
return ContractType; | ||
}({}); | ||
let EventLogType = /*#__PURE__*/function (EventLogType) { | ||
EventLogType["UNKNOWN"] = "UNKNOWN"; | ||
EventLogType["BLOCK_ADDED"] = "BLOCK_ADDED"; | ||
EventLogType["BLOCK_REMOVED"] = "BLOCK_REMOVED"; | ||
return EventLogType; | ||
}({}); | ||
let EventLogDataType = /*#__PURE__*/function (EventLogDataType) { | ||
EventLogDataType["EVENT"] = "EVENT"; | ||
EventLogDataType["TOKEN_TRANSFER"] = "TOKEN_TRANSFER"; | ||
EventLogDataType["NATIVE_TOKEN_TRANSFER"] = "NATIVE_TOKEN_TRANSFER"; | ||
EventLogDataType["SEQUENCE_TXN"] = "SEQUENCE_TXN"; | ||
return EventLogDataType; | ||
}({}); | ||
let OrderStatus = /*#__PURE__*/function (OrderStatus) { | ||
OrderStatus["OPEN"] = "OPEN"; | ||
OrderStatus["CLOSED"] = "CLOSED"; | ||
OrderStatus["CANCELLED"] = "CANCELLED"; | ||
return OrderStatus; | ||
}({}); | ||
let TxnTransferType = /*#__PURE__*/function (TxnTransferType) { | ||
TxnTransferType["UNKNOWN"] = "UNKNOWN"; | ||
TxnTransferType["SEND"] = "SEND"; | ||
TxnTransferType["RECEIVE"] = "RECEIVE"; | ||
return TxnTransferType; | ||
}({}); | ||
let TransactionStatus = /*#__PURE__*/function (TransactionStatus) { | ||
TransactionStatus["FAILED"] = "FAILED"; | ||
TransactionStatus["SUCCESSFUL"] = "SUCCESSFUL"; | ||
return TransactionStatus; | ||
}({}); | ||
let TransactionType = /*#__PURE__*/function (TransactionType) { | ||
TransactionType["LegacyTxnType"] = "LegacyTxnType"; | ||
TransactionType["AccessListTxnType"] = "AccessListTxnType"; | ||
TransactionType["DynamicFeeTxnType"] = "DynamicFeeTxnType"; | ||
return TransactionType; | ||
}({}); | ||
let SortOrder = /*#__PURE__*/function (SortOrder) { | ||
SortOrder["DESC"] = "DESC"; | ||
SortOrder["ASC"] = "ASC"; | ||
return SortOrder; | ||
}({}); | ||
let ContractVerificationStatus = /*#__PURE__*/function (ContractVerificationStatus) { | ||
ContractVerificationStatus["VERIFIED"] = "VERIFIED"; | ||
ContractVerificationStatus["UNVERIFIED"] = "UNVERIFIED"; | ||
ContractVerificationStatus["ALL"] = "ALL"; | ||
return ContractVerificationStatus; | ||
}({}); | ||
// | ||
// Client | ||
// | ||
class IndexerGateway { | ||
constructor(hostname, fetch) { | ||
this.hostname = void 0; | ||
this.fetch = void 0; | ||
this.path = '/rpc/IndexerGateway/'; | ||
this.getNativeTokenBalance = (args, headers, signal) => { | ||
return this.fetch(this.url('GetNativeTokenBalance'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
balances: _data.balances | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.getTokenBalances = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalances'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: _data.page, | ||
balances: _data.balances | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.getTokenBalancesSummary = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalancesSummary'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: _data.page, | ||
balances: _data.balances | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.getTokenBalancesDetails = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalancesDetails'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: _data.page, | ||
balances: _data.balances | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.getTokenBalancesByContract = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalancesByContract'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: _data.page, | ||
balances: _data.balances | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.getBalanceUpdates = (args, headers, signal) => { | ||
return this.fetch(this.url('GetBalanceUpdates'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: _data.page, | ||
balances: _data.balances | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.ping = (headers, signal) => { | ||
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
status: _data.status | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.version = (headers, signal) => { | ||
return this.fetch(this.url('Version'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
version: _data.version | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.runtimeStatus = (headers, signal) => { | ||
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
status: _data.status | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.hostname = hostname.replace(/\/*$/, ''); | ||
this.fetch = (input, init) => fetch(input, init); | ||
} | ||
url(name) { | ||
return this.hostname + this.path + name; | ||
} | ||
} | ||
const createHTTPRequest = (body = {}, headers = {}, signal = null) => { | ||
const reqHeaders = _extends({}, headers, { | ||
'Content-Type': 'application/json' | ||
}); | ||
reqHeaders[WebrpcHeader] = WebrpcHeaderValue; | ||
return { | ||
method: 'POST', | ||
headers: reqHeaders, | ||
body: JSON.stringify(body || {}), | ||
signal | ||
}; | ||
}; | ||
const buildResponse = res => { | ||
@@ -838,4 +1366,82 @@ return res.text().then(text => { | ||
} | ||
class GeoblockedError extends WebrpcError { | ||
constructor(name = 'Geoblocked', code = 1006, message = 'Geoblocked region', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, GeoblockedError.prototype); | ||
} | ||
} | ||
class RateLimitedError extends WebrpcError { | ||
constructor(name = 'RateLimited', code = 1007, message = 'Rate-limited. Please slow down.', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, RateLimitedError.prototype); | ||
} | ||
} | ||
class ProjectNotFoundError extends WebrpcError { | ||
constructor(name = 'ProjectNotFound', code = 1100, message = 'Project not found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, ProjectNotFoundError.prototype); | ||
} | ||
} | ||
class AccessKeyNotFoundError extends WebrpcError { | ||
constructor(name = 'AccessKeyNotFound', code = 1101, message = 'Access key not found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, AccessKeyNotFoundError.prototype); | ||
} | ||
} | ||
class AccessKeyMismatchError extends WebrpcError { | ||
constructor(name = 'AccessKeyMismatch', code = 1102, message = 'Access key mismatch', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, AccessKeyMismatchError.prototype); | ||
} | ||
} | ||
class InvalidOriginError extends WebrpcError { | ||
constructor(name = 'InvalidOrigin', code = 1103, message = 'Invalid origin for Access Key', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, InvalidOriginError.prototype); | ||
} | ||
} | ||
class InvalidServiceError extends WebrpcError { | ||
constructor(name = 'InvalidService', code = 1104, message = 'Service not enabled for Access key', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, InvalidServiceError.prototype); | ||
} | ||
} | ||
class UnauthorizedUserError extends WebrpcError { | ||
constructor(name = 'UnauthorizedUser', code = 1105, message = 'Unauthorized user', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, UnauthorizedUserError.prototype); | ||
} | ||
} | ||
class QuotaExceededError extends WebrpcError { | ||
constructor(name = 'QuotaExceeded', code = 1200, message = 'Quota exceeded', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, QuotaExceededError.prototype); | ||
} | ||
} | ||
class RateLimitError extends WebrpcError { | ||
constructor(name = 'RateLimit', code = 1201, message = 'Rate limit exceeded', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, RateLimitError.prototype); | ||
} | ||
} | ||
class NoDefaultKeyError extends WebrpcError { | ||
constructor(name = 'NoDefaultKey', code = 1300, message = 'No default access key found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, NoDefaultKeyError.prototype); | ||
} | ||
} | ||
class MaxAccessKeysError extends WebrpcError { | ||
constructor(name = 'MaxAccessKeys', code = 1301, message = 'Access keys limit reached', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, MaxAccessKeysError.prototype); | ||
} | ||
} | ||
class AtLeastOneKeyError extends WebrpcError { | ||
constructor(name = 'AtLeastOneKey', code = 1302, message = 'You need at least one Access Key', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, AtLeastOneKeyError.prototype); | ||
} | ||
} | ||
class TimeoutError extends WebrpcError { | ||
constructor(name = 'Timeout', code = 2000, message = 'Request timed out', status = 0, cause) { | ||
constructor(name = 'Timeout', code = 1900, message = 'Request timed out', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
@@ -875,8 +1481,2 @@ Object.setPrototypeOf(this, TimeoutError.prototype); | ||
} | ||
class ProjectNotFoundError extends WebrpcError { | ||
constructor(name = 'ProjectNotFound', code = 3002, message = 'Project not found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, ProjectNotFoundError.prototype); | ||
} | ||
} | ||
class MetadataCallFailedError extends WebrpcError { | ||
@@ -906,2 +1506,15 @@ constructor(name = 'MetadataCallFailed', code = 3003, message = 'Metadata service call failed', status = 0, cause) { | ||
errors["Aborted"] = "Aborted"; | ||
errors["Geoblocked"] = "Geoblocked"; | ||
errors["RateLimited"] = "RateLimited"; | ||
errors["ProjectNotFound"] = "ProjectNotFound"; | ||
errors["AccessKeyNotFound"] = "AccessKeyNotFound"; | ||
errors["AccessKeyMismatch"] = "AccessKeyMismatch"; | ||
errors["InvalidOrigin"] = "InvalidOrigin"; | ||
errors["InvalidService"] = "InvalidService"; | ||
errors["UnauthorizedUser"] = "UnauthorizedUser"; | ||
errors["QuotaExceeded"] = "QuotaExceeded"; | ||
errors["RateLimit"] = "RateLimit"; | ||
errors["NoDefaultKey"] = "NoDefaultKey"; | ||
errors["MaxAccessKeys"] = "MaxAccessKeys"; | ||
errors["AtLeastOneKey"] = "AtLeastOneKey"; | ||
errors["Timeout"] = "Timeout"; | ||
@@ -913,3 +1526,2 @@ errors["InvalidArgument"] = "InvalidArgument"; | ||
errors["NotFound"] = "NotFound"; | ||
errors["ProjectNotFound"] = "ProjectNotFound"; | ||
errors["MetadataCallFailed"] = "MetadataCallFailed"; | ||
@@ -936,3 +1548,16 @@ return errors; | ||
[1005]: AbortedError, | ||
[2000]: TimeoutError, | ||
[1006]: GeoblockedError, | ||
[1007]: RateLimitedError, | ||
[1100]: ProjectNotFoundError, | ||
[1101]: AccessKeyNotFoundError, | ||
[1102]: AccessKeyMismatchError, | ||
[1103]: InvalidOriginError, | ||
[1104]: InvalidServiceError, | ||
[1105]: UnauthorizedUserError, | ||
[1200]: QuotaExceededError, | ||
[1201]: RateLimitError, | ||
[1300]: NoDefaultKeyError, | ||
[1301]: MaxAccessKeysError, | ||
[1302]: AtLeastOneKeyError, | ||
[1900]: TimeoutError, | ||
[2001]: InvalidArgumentError, | ||
@@ -943,6 +1568,64 @@ [2002]: UnavailableError, | ||
[3000]: NotFoundError, | ||
[3002]: ProjectNotFoundError, | ||
[3003]: MetadataCallFailedError | ||
}; | ||
var indexergw_gen = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
WebrpcHeader: WebrpcHeader, | ||
WebrpcHeaderValue: WebrpcHeaderValue, | ||
WebRPCVersion: WebRPCVersion, | ||
WebRPCSchemaVersion: WebRPCSchemaVersion, | ||
WebRPCSchemaHash: WebRPCSchemaHash, | ||
VersionFromHeader: VersionFromHeader, | ||
ContractType: ContractType, | ||
EventLogType: EventLogType, | ||
EventLogDataType: EventLogDataType, | ||
OrderStatus: OrderStatus, | ||
TxnTransferType: TxnTransferType, | ||
TransactionStatus: TransactionStatus, | ||
TransactionType: TransactionType, | ||
SortOrder: SortOrder, | ||
ContractVerificationStatus: ContractVerificationStatus, | ||
IndexerGateway: IndexerGateway, | ||
WebrpcError: WebrpcError, | ||
WebrpcEndpointError: WebrpcEndpointError, | ||
WebrpcRequestFailedError: WebrpcRequestFailedError, | ||
WebrpcBadRouteError: WebrpcBadRouteError, | ||
WebrpcBadMethodError: WebrpcBadMethodError, | ||
WebrpcBadRequestError: WebrpcBadRequestError, | ||
WebrpcBadResponseError: WebrpcBadResponseError, | ||
WebrpcServerPanicError: WebrpcServerPanicError, | ||
WebrpcInternalErrorError: WebrpcInternalErrorError, | ||
WebrpcClientDisconnectedError: WebrpcClientDisconnectedError, | ||
WebrpcStreamLostError: WebrpcStreamLostError, | ||
WebrpcStreamFinishedError: WebrpcStreamFinishedError, | ||
UnauthorizedError: UnauthorizedError, | ||
PermissionDeniedError: PermissionDeniedError, | ||
SessionExpiredError: SessionExpiredError, | ||
MethodNotFoundError: MethodNotFoundError, | ||
RequestConflictError: RequestConflictError, | ||
AbortedError: AbortedError, | ||
GeoblockedError: GeoblockedError, | ||
RateLimitedError: RateLimitedError, | ||
ProjectNotFoundError: ProjectNotFoundError, | ||
AccessKeyNotFoundError: AccessKeyNotFoundError, | ||
AccessKeyMismatchError: AccessKeyMismatchError, | ||
InvalidOriginError: InvalidOriginError, | ||
InvalidServiceError: InvalidServiceError, | ||
UnauthorizedUserError: UnauthorizedUserError, | ||
QuotaExceededError: QuotaExceededError, | ||
RateLimitError: RateLimitError, | ||
NoDefaultKeyError: NoDefaultKeyError, | ||
MaxAccessKeysError: MaxAccessKeysError, | ||
AtLeastOneKeyError: AtLeastOneKeyError, | ||
TimeoutError: TimeoutError, | ||
InvalidArgumentError: InvalidArgumentError, | ||
UnavailableError: UnavailableError, | ||
QueryFailedError: QueryFailedError, | ||
ResourceExhaustedError: ResourceExhaustedError, | ||
NotFoundError: NotFoundError, | ||
MetadataCallFailedError: MetadataCallFailedError, | ||
errors: errors | ||
}); | ||
class SequenceIndexer extends Indexer { | ||
@@ -973,43 +1656,70 @@ constructor(hostname, projectAccessKey, jwtAuth) { | ||
} | ||
class SequenceIndexerGateway extends IndexerGateway { | ||
constructor(hostname, projectAccessKey, jwtAuth) { | ||
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch); | ||
this.projectAccessKey = projectAccessKey; | ||
this.jwtAuth = jwtAuth; | ||
this._fetch = (input, init) => { | ||
// automatically include jwt and access key auth header to requests | ||
// if its been set on the api client | ||
const headers = {}; | ||
const jwtAuth = this.jwtAuth; | ||
const projectAccessKey = this.projectAccessKey; | ||
if (jwtAuth && jwtAuth.length > 0) { | ||
headers['Authorization'] = `BEARER ${jwtAuth}`; | ||
} | ||
if (projectAccessKey && projectAccessKey.length > 0) { | ||
headers['X-Access-Key'] = projectAccessKey; | ||
} | ||
exports.AbortedError = AbortedError; | ||
exports.ContractType = ContractType; | ||
exports.ContractVerificationStatus = ContractVerificationStatus; | ||
exports.EventLogDataType = EventLogDataType; | ||
exports.EventLogType = EventLogType; | ||
// before the request is made | ||
init.headers = _extends({}, init.headers, headers); | ||
return fetch(input, init); | ||
}; | ||
this.fetch = this._fetch; | ||
} | ||
} | ||
exports.AbortedError = AbortedError$1; | ||
exports.ContractType = ContractType$1; | ||
exports.ContractVerificationStatus = ContractVerificationStatus$1; | ||
exports.EventLogDataType = EventLogDataType$1; | ||
exports.EventLogType = EventLogType$1; | ||
exports.Indexer = Indexer; | ||
exports.InvalidArgumentError = InvalidArgumentError; | ||
exports.MetadataCallFailedError = MetadataCallFailedError; | ||
exports.MethodNotFoundError = MethodNotFoundError; | ||
exports.NotFoundError = NotFoundError; | ||
exports.OrderStatus = OrderStatus; | ||
exports.PermissionDeniedError = PermissionDeniedError; | ||
exports.ProjectNotFoundError = ProjectNotFoundError; | ||
exports.QueryFailedError = QueryFailedError; | ||
exports.RequestConflictError = RequestConflictError; | ||
exports.ResourceExhaustedError = ResourceExhaustedError; | ||
exports.IndexerGateway = indexergw_gen; | ||
exports.InvalidArgumentError = InvalidArgumentError$1; | ||
exports.MetadataCallFailedError = MetadataCallFailedError$1; | ||
exports.MethodNotFoundError = MethodNotFoundError$1; | ||
exports.NotFoundError = NotFoundError$1; | ||
exports.OrderStatus = OrderStatus$1; | ||
exports.PermissionDeniedError = PermissionDeniedError$1; | ||
exports.ProjectNotFoundError = ProjectNotFoundError$1; | ||
exports.QueryFailedError = QueryFailedError$1; | ||
exports.RequestConflictError = RequestConflictError$1; | ||
exports.ResourceExhaustedError = ResourceExhaustedError$1; | ||
exports.SequenceIndexer = SequenceIndexer; | ||
exports.SessionExpiredError = SessionExpiredError; | ||
exports.SortOrder = SortOrder; | ||
exports.TimeoutError = TimeoutError; | ||
exports.TransactionStatus = TransactionStatus; | ||
exports.TransactionType = TransactionType; | ||
exports.TxnTransferType = TxnTransferType; | ||
exports.UnauthorizedError = UnauthorizedError; | ||
exports.UnavailableError = UnavailableError; | ||
exports.WebRPCSchemaHash = WebRPCSchemaHash; | ||
exports.WebRPCSchemaVersion = WebRPCSchemaVersion; | ||
exports.WebRPCVersion = WebRPCVersion; | ||
exports.WebrpcBadMethodError = WebrpcBadMethodError; | ||
exports.WebrpcBadRequestError = WebrpcBadRequestError; | ||
exports.WebrpcBadResponseError = WebrpcBadResponseError; | ||
exports.WebrpcBadRouteError = WebrpcBadRouteError; | ||
exports.WebrpcClientDisconnectedError = WebrpcClientDisconnectedError; | ||
exports.WebrpcEndpointError = WebrpcEndpointError; | ||
exports.WebrpcError = WebrpcError; | ||
exports.WebrpcInternalErrorError = WebrpcInternalErrorError; | ||
exports.WebrpcRequestFailedError = WebrpcRequestFailedError; | ||
exports.WebrpcServerPanicError = WebrpcServerPanicError; | ||
exports.WebrpcStreamFinishedError = WebrpcStreamFinishedError; | ||
exports.WebrpcStreamLostError = WebrpcStreamLostError; | ||
exports.errors = errors; | ||
exports.SequenceIndexerGateway = SequenceIndexerGateway; | ||
exports.SessionExpiredError = SessionExpiredError$1; | ||
exports.SortOrder = SortOrder$1; | ||
exports.TimeoutError = TimeoutError$1; | ||
exports.TransactionStatus = TransactionStatus$1; | ||
exports.TransactionType = TransactionType$1; | ||
exports.TxnTransferType = TxnTransferType$1; | ||
exports.UnauthorizedError = UnauthorizedError$1; | ||
exports.UnavailableError = UnavailableError$1; | ||
exports.WebRPCSchemaHash = WebRPCSchemaHash$1; | ||
exports.WebRPCSchemaVersion = WebRPCSchemaVersion$1; | ||
exports.WebRPCVersion = WebRPCVersion$1; | ||
exports.WebrpcBadMethodError = WebrpcBadMethodError$1; | ||
exports.WebrpcBadRequestError = WebrpcBadRequestError$1; | ||
exports.WebrpcBadResponseError = WebrpcBadResponseError$1; | ||
exports.WebrpcBadRouteError = WebrpcBadRouteError$1; | ||
exports.WebrpcClientDisconnectedError = WebrpcClientDisconnectedError$1; | ||
exports.WebrpcEndpointError = WebrpcEndpointError$1; | ||
exports.WebrpcError = WebrpcError$1; | ||
exports.WebrpcInternalErrorError = WebrpcInternalErrorError$1; | ||
exports.WebrpcRequestFailedError = WebrpcRequestFailedError$1; | ||
exports.WebrpcServerPanicError = WebrpcServerPanicError$1; | ||
exports.WebrpcStreamFinishedError = WebrpcStreamFinishedError$1; | ||
exports.WebrpcStreamLostError = WebrpcStreamLostError$1; | ||
exports.errors = errors$1; |
@@ -23,9 +23,9 @@ 'use strict'; | ||
// WebRPC description and code-gen version | ||
const WebRPCVersion = 'v1'; | ||
const WebRPCVersion$1 = 'v1'; | ||
// Schema version of your RIDL schema | ||
const WebRPCSchemaVersion = 'v0.4.0'; | ||
const WebRPCSchemaVersion$1 = 'v0.4.0'; | ||
// Schema hash generated from your RIDL schema | ||
const WebRPCSchemaHash = 'cae735346d8e5c3dce48dce9f85116989b6beffd'; | ||
const WebRPCSchemaHash$1 = 'cae735346d8e5c3dce48dce9f85116989b6beffd'; | ||
@@ -36,3 +36,3 @@ // | ||
let ContractType = /*#__PURE__*/function (ContractType) { | ||
let ContractType$1 = /*#__PURE__*/function (ContractType) { | ||
ContractType["UNKNOWN"] = "UNKNOWN"; | ||
@@ -50,3 +50,3 @@ ContractType["NATIVE"] = "NATIVE"; | ||
}({}); | ||
let EventLogType = /*#__PURE__*/function (EventLogType) { | ||
let EventLogType$1 = /*#__PURE__*/function (EventLogType) { | ||
EventLogType["UNKNOWN"] = "UNKNOWN"; | ||
@@ -57,3 +57,3 @@ EventLogType["BLOCK_ADDED"] = "BLOCK_ADDED"; | ||
}({}); | ||
let EventLogDataType = /*#__PURE__*/function (EventLogDataType) { | ||
let EventLogDataType$1 = /*#__PURE__*/function (EventLogDataType) { | ||
EventLogDataType["EVENT"] = "EVENT"; | ||
@@ -65,3 +65,3 @@ EventLogDataType["TOKEN_TRANSFER"] = "TOKEN_TRANSFER"; | ||
}({}); | ||
let OrderStatus = /*#__PURE__*/function (OrderStatus) { | ||
let OrderStatus$1 = /*#__PURE__*/function (OrderStatus) { | ||
OrderStatus["OPEN"] = "OPEN"; | ||
@@ -72,3 +72,3 @@ OrderStatus["CLOSED"] = "CLOSED"; | ||
}({}); | ||
let TxnTransferType = /*#__PURE__*/function (TxnTransferType) { | ||
let TxnTransferType$1 = /*#__PURE__*/function (TxnTransferType) { | ||
TxnTransferType["UNKNOWN"] = "UNKNOWN"; | ||
@@ -79,3 +79,3 @@ TxnTransferType["SEND"] = "SEND"; | ||
}({}); | ||
let TransactionStatus = /*#__PURE__*/function (TransactionStatus) { | ||
let TransactionStatus$1 = /*#__PURE__*/function (TransactionStatus) { | ||
TransactionStatus["FAILED"] = "FAILED"; | ||
@@ -85,3 +85,3 @@ TransactionStatus["SUCCESSFUL"] = "SUCCESSFUL"; | ||
}({}); | ||
let TransactionType = /*#__PURE__*/function (TransactionType) { | ||
let TransactionType$1 = /*#__PURE__*/function (TransactionType) { | ||
TransactionType["LegacyTxnType"] = "LegacyTxnType"; | ||
@@ -92,3 +92,3 @@ TransactionType["AccessListTxnType"] = "AccessListTxnType"; | ||
}({}); | ||
let SortOrder = /*#__PURE__*/function (SortOrder) { | ||
let SortOrder$1 = /*#__PURE__*/function (SortOrder) { | ||
SortOrder["DESC"] = "DESC"; | ||
@@ -98,3 +98,3 @@ SortOrder["ASC"] = "ASC"; | ||
}({}); | ||
let ContractVerificationStatus = /*#__PURE__*/function (ContractVerificationStatus) { | ||
let ContractVerificationStatus$1 = /*#__PURE__*/function (ContractVerificationStatus) { | ||
ContractVerificationStatus["VERIFIED"] = "VERIFIED"; | ||
@@ -114,4 +114,4 @@ ContractVerificationStatus["UNVERIFIED"] = "UNVERIFIED"; | ||
this.ping = (headers, signal) => { | ||
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('Ping'), createHTTPRequest$1({}, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -122,3 +122,3 @@ status: _data.status | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -129,4 +129,4 @@ }); | ||
this.version = (headers, signal) => { | ||
return this.fetch(this.url('Version'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('Version'), createHTTPRequest$1({}, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -137,3 +137,3 @@ version: _data.version | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -144,4 +144,4 @@ }); | ||
this.runtimeStatus = (headers, signal) => { | ||
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest$1({}, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -152,3 +152,3 @@ status: _data.status | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -159,4 +159,4 @@ }); | ||
this.getChainID = (headers, signal) => { | ||
return this.fetch(this.url('GetChainID'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetChainID'), createHTTPRequest$1({}, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -167,3 +167,3 @@ chainID: _data.chainID | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -174,4 +174,4 @@ }); | ||
this.getEtherBalance = (args, headers, signal) => { | ||
return this.fetch(this.url('GetEtherBalance'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetEtherBalance'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -182,3 +182,3 @@ balance: _data.balance | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -189,4 +189,4 @@ }); | ||
this.getNativeTokenBalance = (args, headers, signal) => { | ||
return this.fetch(this.url('GetNativeTokenBalance'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetNativeTokenBalance'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -197,3 +197,3 @@ balance: _data.balance | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -204,4 +204,4 @@ }); | ||
this.getTokenBalancesSummary = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalancesSummary'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTokenBalancesSummary'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -213,3 +213,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -220,4 +220,4 @@ }); | ||
this.getTokenBalancesDetails = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalancesDetails'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTokenBalancesDetails'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -229,3 +229,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -236,4 +236,4 @@ }); | ||
this.getTokenBalancesByContract = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalancesByContract'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTokenBalancesByContract'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -245,3 +245,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -252,4 +252,4 @@ }); | ||
this.getTokenBalances = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalances'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTokenBalances'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -261,3 +261,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -268,4 +268,4 @@ }); | ||
this.getTokenSupplies = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenSupplies'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTokenSupplies'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -278,3 +278,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -285,4 +285,4 @@ }); | ||
this.getTokenSuppliesMap = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenSuppliesMap'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTokenSuppliesMap'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -293,3 +293,3 @@ supplies: _data.supplies | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -300,4 +300,4 @@ }); | ||
this.getBalanceUpdates = (args, headers, signal) => { | ||
return this.fetch(this.url('GetBalanceUpdates'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetBalanceUpdates'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -309,3 +309,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -316,4 +316,4 @@ }); | ||
this.getTransactionHistory = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTransactionHistory'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTransactionHistory'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -325,3 +325,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -332,8 +332,8 @@ }); | ||
this.syncBalance = (args, headers, signal) => { | ||
return this.fetch(this.url('SyncBalance'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('SyncBalance'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return {}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -344,4 +344,4 @@ }); | ||
this.fetchTransactionReceipt = (args, headers, signal) => { | ||
return this.fetch(this.url('FetchTransactionReceipt'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('FetchTransactionReceipt'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -352,3 +352,3 @@ receipt: _data.receipt | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -359,4 +359,4 @@ }); | ||
this.getOrderbookOrders = (args, headers, signal) => { | ||
return this.fetch(this.url('GetOrderbookOrders'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetOrderbookOrders'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -368,3 +368,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -375,4 +375,4 @@ }); | ||
this.getTopOrders = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTopOrders'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTopOrders'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -383,3 +383,3 @@ orders: _data.orders | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -390,4 +390,4 @@ }); | ||
this.fetchTransactionReceiptWithFilter = (args, headers, signal) => { | ||
return this.fetch(this.url('FetchTransactionReceiptWithFilter'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('FetchTransactionReceiptWithFilter'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -398,3 +398,3 @@ receipt: _data.receipt | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -405,4 +405,4 @@ }); | ||
this.getAllWebhookListeners = (args, headers, signal) => { | ||
return this.fetch(this.url('GetAllWebhookListeners'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetAllWebhookListeners'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -413,3 +413,3 @@ listeners: _data.listeners | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -420,4 +420,4 @@ }); | ||
this.getWebhookListener = (args, headers, signal) => { | ||
return this.fetch(this.url('GetWebhookListener'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -428,3 +428,3 @@ listener: _data.listener | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -435,4 +435,4 @@ }); | ||
this.addWebhookListener = (args, headers, signal) => { | ||
return this.fetch(this.url('AddWebhookListener'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('AddWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -444,3 +444,3 @@ status: _data.status, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -451,4 +451,4 @@ }); | ||
this.updateWebhookListener = (args, headers, signal) => { | ||
return this.fetch(this.url('UpdateWebhookListener'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('UpdateWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -459,3 +459,3 @@ status: _data.status | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -466,4 +466,4 @@ }); | ||
this.removeWebhookListener = (args, headers, signal) => { | ||
return this.fetch(this.url('RemoveWebhookListener'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('RemoveWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -474,3 +474,3 @@ status: _data.status | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -481,4 +481,4 @@ }); | ||
this.toggleWebhookListener = (args, headers, signal) => { | ||
return this.fetch(this.url('ToggleWebhookListener'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('ToggleWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -489,3 +489,3 @@ webhookListener: _data.webhookListener | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -496,4 +496,4 @@ }); | ||
this.pauseAllWebhookListeners = (args, headers, signal) => { | ||
return this.fetch(this.url('PauseAllWebhookListeners'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('PauseAllWebhookListeners'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -504,3 +504,3 @@ status: _data.status | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -511,4 +511,4 @@ }); | ||
this.resumeAllWebhookListeners = (args, headers, signal) => { | ||
return this.fetch(this.url('ResumeAllWebhookListeners'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('ResumeAllWebhookListeners'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -519,3 +519,3 @@ status: _data.status | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -526,3 +526,3 @@ }); | ||
this.subscribeReceipts = (args, options) => { | ||
const _fetch = () => this.fetch(this.url('SubscribeReceipts'), createHTTPRequest(args, options.headers, options.signal)).then(async function (res) { | ||
const _fetch = () => this.fetch(this.url('SubscribeReceipts'), createHTTPRequest$1(args, options.headers, options.signal)).then(async function (res) { | ||
await sseResponse(res, options, _fetch); | ||
@@ -535,3 +535,3 @@ }, error => { | ||
this.subscribeEvents = (args, options) => { | ||
const _fetch = () => this.fetch(this.url('SubscribeEvents'), createHTTPRequest(args, options.headers, options.signal)).then(async function (res) { | ||
const _fetch = () => this.fetch(this.url('SubscribeEvents'), createHTTPRequest$1(args, options.headers, options.signal)).then(async function (res) { | ||
await sseResponse(res, options, _fetch); | ||
@@ -544,3 +544,3 @@ }, error => { | ||
this.subscribeBalanceUpdates = (args, options) => { | ||
const _fetch = () => this.fetch(this.url('SubscribeBalanceUpdates'), createHTTPRequest(args, options.headers, options.signal)).then(async function (res) { | ||
const _fetch = () => this.fetch(this.url('SubscribeBalanceUpdates'), createHTTPRequest$1(args, options.headers, options.signal)).then(async function (res) { | ||
await sseResponse(res, options, _fetch); | ||
@@ -568,3 +568,3 @@ }, error => { | ||
try { | ||
await buildResponse(res); | ||
await buildResponse$1(res); | ||
} catch (error) { | ||
@@ -577,3 +577,3 @@ // @ts-ignore | ||
if (!res.body) { | ||
onError(WebrpcBadResponseError.new({ | ||
onError(WebrpcBadResponseError$1.new({ | ||
status: res.status, | ||
@@ -618,3 +618,3 @@ cause: 'Invalid response, missing body' | ||
if (error instanceof DOMException && error.name === 'AbortError') { | ||
onError(WebrpcRequestFailedError.new({ | ||
onError(WebrpcRequestFailedError$1.new({ | ||
message: 'AbortError', | ||
@@ -626,3 +626,3 @@ cause: `AbortError: ${message}` | ||
} else { | ||
onError(WebrpcStreamLostError.new({ | ||
onError(WebrpcStreamLostError$1.new({ | ||
cause: `reader.read(): ${message}` | ||
@@ -644,3 +644,3 @@ }), retryFetch); | ||
const code = typeof error.code === 'number' ? error.code : 0; | ||
onError((webrpcErrorByCode[code] || WebrpcError).new(error), retryFetch); | ||
onError((webrpcErrorByCode$1[code] || WebrpcError$1).new(error), retryFetch); | ||
return; | ||
@@ -652,3 +652,3 @@ } | ||
} | ||
onError(WebrpcBadResponseError.new({ | ||
onError(WebrpcBadResponseError$1.new({ | ||
status: res.status, | ||
@@ -669,3 +669,3 @@ // @ts-ignore | ||
}; | ||
const createHTTPRequest = (body = {}, headers = {}, signal = null) => { | ||
const createHTTPRequest$1 = (body = {}, headers = {}, signal = null) => { | ||
return { | ||
@@ -680,2 +680,530 @@ method: 'POST', | ||
}; | ||
const buildResponse$1 = res => { | ||
return res.text().then(text => { | ||
let data; | ||
try { | ||
data = JSON.parse(text); | ||
} catch (error) { | ||
let message = ''; | ||
if (error instanceof Error) { | ||
message = error.message; | ||
} | ||
throw WebrpcBadResponseError$1.new({ | ||
status: res.status, | ||
cause: `JSON.parse(): ${message}: response text: ${text}` | ||
}); | ||
} | ||
if (!res.ok) { | ||
const code = typeof data.code === 'number' ? data.code : 0; | ||
throw (webrpcErrorByCode$1[code] || WebrpcError$1).new(data); | ||
} | ||
return data; | ||
}); | ||
}; | ||
// | ||
// Errors | ||
// | ||
class WebrpcError$1 extends Error { | ||
constructor(name, code, message, status, cause) { | ||
super(message); | ||
this.name = void 0; | ||
this.code = void 0; | ||
this.message = void 0; | ||
this.status = void 0; | ||
this.cause = void 0; | ||
/** @deprecated Use message instead of msg. Deprecated in webrpc v0.11.0. */ | ||
this.msg = void 0; | ||
this.name = name || 'WebrpcError'; | ||
this.code = typeof code === 'number' ? code : 0; | ||
this.message = message || `endpoint error ${this.code}`; | ||
this.msg = this.message; | ||
this.status = typeof status === 'number' ? status : 0; | ||
this.cause = cause; | ||
Object.setPrototypeOf(this, WebrpcError$1.prototype); | ||
} | ||
static new(payload) { | ||
return new this(payload.error, payload.code, payload.message || payload.msg, payload.status, payload.cause); | ||
} | ||
} | ||
// Webrpc errors | ||
class WebrpcEndpointError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcEndpoint', code = 0, message = 'endpoint error', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcEndpointError$1.prototype); | ||
} | ||
} | ||
class WebrpcRequestFailedError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcRequestFailed', code = -1, message = 'request failed', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcRequestFailedError$1.prototype); | ||
} | ||
} | ||
class WebrpcBadRouteError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcBadRoute', code = -2, message = 'bad route', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcBadRouteError$1.prototype); | ||
} | ||
} | ||
class WebrpcBadMethodError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcBadMethod', code = -3, message = 'bad method', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcBadMethodError$1.prototype); | ||
} | ||
} | ||
class WebrpcBadRequestError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcBadRequest', code = -4, message = 'bad request', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcBadRequestError$1.prototype); | ||
} | ||
} | ||
class WebrpcBadResponseError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcBadResponse', code = -5, message = 'bad response', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcBadResponseError$1.prototype); | ||
} | ||
} | ||
class WebrpcServerPanicError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcServerPanic', code = -6, message = 'server panic', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcServerPanicError$1.prototype); | ||
} | ||
} | ||
class WebrpcInternalErrorError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcInternalError', code = -7, message = 'internal error', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcInternalErrorError$1.prototype); | ||
} | ||
} | ||
class WebrpcClientDisconnectedError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcClientDisconnected', code = -8, message = 'client disconnected', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcClientDisconnectedError$1.prototype); | ||
} | ||
} | ||
class WebrpcStreamLostError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcStreamLost', code = -9, message = 'stream lost', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcStreamLostError$1.prototype); | ||
} | ||
} | ||
class WebrpcStreamFinishedError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcStreamFinished', code = -10, message = 'stream finished', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcStreamFinishedError$1.prototype); | ||
} | ||
} | ||
// Schema errors | ||
class UnauthorizedError$1 extends WebrpcError$1 { | ||
constructor(name = 'Unauthorized', code = 1000, message = 'Unauthorized access', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, UnauthorizedError$1.prototype); | ||
} | ||
} | ||
class PermissionDeniedError$1 extends WebrpcError$1 { | ||
constructor(name = 'PermissionDenied', code = 1001, message = 'Permission denied', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, PermissionDeniedError$1.prototype); | ||
} | ||
} | ||
class SessionExpiredError$1 extends WebrpcError$1 { | ||
constructor(name = 'SessionExpired', code = 1002, message = 'Session expired', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, SessionExpiredError$1.prototype); | ||
} | ||
} | ||
class MethodNotFoundError$1 extends WebrpcError$1 { | ||
constructor(name = 'MethodNotFound', code = 1003, message = 'Method not found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, MethodNotFoundError$1.prototype); | ||
} | ||
} | ||
class RequestConflictError$1 extends WebrpcError$1 { | ||
constructor(name = 'RequestConflict', code = 1004, message = 'Conflict with target resource', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, RequestConflictError$1.prototype); | ||
} | ||
} | ||
class AbortedError$1 extends WebrpcError$1 { | ||
constructor(name = 'Aborted', code = 1005, message = 'Request aborted', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, AbortedError$1.prototype); | ||
} | ||
} | ||
class TimeoutError$1 extends WebrpcError$1 { | ||
constructor(name = 'Timeout', code = 2000, message = 'Request timed out', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, TimeoutError$1.prototype); | ||
} | ||
} | ||
class InvalidArgumentError$1 extends WebrpcError$1 { | ||
constructor(name = 'InvalidArgument', code = 2001, message = 'Invalid argument', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, InvalidArgumentError$1.prototype); | ||
} | ||
} | ||
class UnavailableError$1 extends WebrpcError$1 { | ||
constructor(name = 'Unavailable', code = 2002, message = 'Unavailable resource', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, UnavailableError$1.prototype); | ||
} | ||
} | ||
class QueryFailedError$1 extends WebrpcError$1 { | ||
constructor(name = 'QueryFailed', code = 2003, message = 'Query failed', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, QueryFailedError$1.prototype); | ||
} | ||
} | ||
class ResourceExhaustedError$1 extends WebrpcError$1 { | ||
constructor(name = 'ResourceExhausted', code = 2004, message = 'Resource exhausted', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, ResourceExhaustedError$1.prototype); | ||
} | ||
} | ||
class NotFoundError$1 extends WebrpcError$1 { | ||
constructor(name = 'NotFound', code = 3000, message = 'Resource not found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, NotFoundError$1.prototype); | ||
} | ||
} | ||
class ProjectNotFoundError$1 extends WebrpcError$1 { | ||
constructor(name = 'ProjectNotFound', code = 3002, message = 'Project not found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, ProjectNotFoundError$1.prototype); | ||
} | ||
} | ||
class MetadataCallFailedError$1 extends WebrpcError$1 { | ||
constructor(name = 'MetadataCallFailed', code = 3003, message = 'Metadata service call failed', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, MetadataCallFailedError$1.prototype); | ||
} | ||
} | ||
let errors$1 = /*#__PURE__*/function (errors) { | ||
errors["WebrpcEndpoint"] = "WebrpcEndpoint"; | ||
errors["WebrpcRequestFailed"] = "WebrpcRequestFailed"; | ||
errors["WebrpcBadRoute"] = "WebrpcBadRoute"; | ||
errors["WebrpcBadMethod"] = "WebrpcBadMethod"; | ||
errors["WebrpcBadRequest"] = "WebrpcBadRequest"; | ||
errors["WebrpcBadResponse"] = "WebrpcBadResponse"; | ||
errors["WebrpcServerPanic"] = "WebrpcServerPanic"; | ||
errors["WebrpcInternalError"] = "WebrpcInternalError"; | ||
errors["WebrpcClientDisconnected"] = "WebrpcClientDisconnected"; | ||
errors["WebrpcStreamLost"] = "WebrpcStreamLost"; | ||
errors["WebrpcStreamFinished"] = "WebrpcStreamFinished"; | ||
errors["Unauthorized"] = "Unauthorized"; | ||
errors["PermissionDenied"] = "PermissionDenied"; | ||
errors["SessionExpired"] = "SessionExpired"; | ||
errors["MethodNotFound"] = "MethodNotFound"; | ||
errors["RequestConflict"] = "RequestConflict"; | ||
errors["Aborted"] = "Aborted"; | ||
errors["Timeout"] = "Timeout"; | ||
errors["InvalidArgument"] = "InvalidArgument"; | ||
errors["Unavailable"] = "Unavailable"; | ||
errors["QueryFailed"] = "QueryFailed"; | ||
errors["ResourceExhausted"] = "ResourceExhausted"; | ||
errors["NotFound"] = "NotFound"; | ||
errors["ProjectNotFound"] = "ProjectNotFound"; | ||
errors["MetadataCallFailed"] = "MetadataCallFailed"; | ||
return errors; | ||
}({}); | ||
const webrpcErrorByCode$1 = { | ||
[0]: WebrpcEndpointError$1, | ||
[-1]: WebrpcRequestFailedError$1, | ||
[-2]: WebrpcBadRouteError$1, | ||
[-3]: WebrpcBadMethodError$1, | ||
[-4]: WebrpcBadRequestError$1, | ||
[-5]: WebrpcBadResponseError$1, | ||
[-6]: WebrpcServerPanicError$1, | ||
[-7]: WebrpcInternalErrorError$1, | ||
[-8]: WebrpcClientDisconnectedError$1, | ||
[-9]: WebrpcStreamLostError$1, | ||
[-10]: WebrpcStreamFinishedError$1, | ||
[1000]: UnauthorizedError$1, | ||
[1001]: PermissionDeniedError$1, | ||
[1002]: SessionExpiredError$1, | ||
[1003]: MethodNotFoundError$1, | ||
[1004]: RequestConflictError$1, | ||
[1005]: AbortedError$1, | ||
[2000]: TimeoutError$1, | ||
[2001]: InvalidArgumentError$1, | ||
[2002]: UnavailableError$1, | ||
[2003]: QueryFailedError$1, | ||
[2004]: ResourceExhaustedError$1, | ||
[3000]: NotFoundError$1, | ||
[3002]: ProjectNotFoundError$1, | ||
[3003]: MetadataCallFailedError$1 | ||
}; | ||
/* eslint-disable */ | ||
// sequence-indexer v0.4.0 71cd081c5ca2372bf92a897ae1aa4ebf93ffd0fc | ||
// -- | ||
// Code generated by webrpc-gen@v0.21.1 with typescript generator. DO NOT EDIT. | ||
// | ||
// webrpc-gen -schema=indexer.ridl -service=IndexerGateway -target=typescript -client -out=./clients/indexergw/indexer.gen.ts | ||
const WebrpcHeader = "Webrpc"; | ||
const WebrpcHeaderValue = "webrpc@v0.21.1;gen-typescript@v0.15.1;sequence-indexer@v0.4.0"; | ||
// WebRPC description and code-gen version | ||
const WebRPCVersion = "v1"; | ||
// Schema version of your RIDL schema | ||
const WebRPCSchemaVersion = "v0.4.0"; | ||
// Schema hash generated from your RIDL schema | ||
const WebRPCSchemaHash = "71cd081c5ca2372bf92a897ae1aa4ebf93ffd0fc"; | ||
function VersionFromHeader(headers) { | ||
const headerValue = headers.get(WebrpcHeader); | ||
if (!headerValue) { | ||
return { | ||
webrpcGenVersion: "", | ||
codeGenName: "", | ||
codeGenVersion: "", | ||
schemaName: "", | ||
schemaVersion: "" | ||
}; | ||
} | ||
return parseWebrpcGenVersions(headerValue); | ||
} | ||
function parseWebrpcGenVersions(header) { | ||
const versions = header.split(";"); | ||
if (versions.length < 3) { | ||
return { | ||
webrpcGenVersion: "", | ||
codeGenName: "", | ||
codeGenVersion: "", | ||
schemaName: "", | ||
schemaVersion: "" | ||
}; | ||
} | ||
const [_, webrpcGenVersion] = versions[0].split("@"); | ||
const [codeGenName, codeGenVersion] = versions[1].split("@"); | ||
const [schemaName, schemaVersion] = versions[2].split("@"); | ||
return { | ||
webrpcGenVersion, | ||
codeGenName, | ||
codeGenVersion, | ||
schemaName, | ||
schemaVersion | ||
}; | ||
} | ||
// | ||
// Types | ||
// | ||
let ContractType = /*#__PURE__*/function (ContractType) { | ||
ContractType["UNKNOWN"] = "UNKNOWN"; | ||
ContractType["NATIVE"] = "NATIVE"; | ||
ContractType["ERC20"] = "ERC20"; | ||
ContractType["ERC721"] = "ERC721"; | ||
ContractType["ERC1155"] = "ERC1155"; | ||
ContractType["SEQUENCE_WALLET"] = "SEQUENCE_WALLET"; | ||
ContractType["ERC20_BRIDGE"] = "ERC20_BRIDGE"; | ||
ContractType["ERC721_BRIDGE"] = "ERC721_BRIDGE"; | ||
ContractType["ERC1155_BRIDGE"] = "ERC1155_BRIDGE"; | ||
ContractType["SEQ_MARKETPLACE"] = "SEQ_MARKETPLACE"; | ||
return ContractType; | ||
}({}); | ||
let EventLogType = /*#__PURE__*/function (EventLogType) { | ||
EventLogType["UNKNOWN"] = "UNKNOWN"; | ||
EventLogType["BLOCK_ADDED"] = "BLOCK_ADDED"; | ||
EventLogType["BLOCK_REMOVED"] = "BLOCK_REMOVED"; | ||
return EventLogType; | ||
}({}); | ||
let EventLogDataType = /*#__PURE__*/function (EventLogDataType) { | ||
EventLogDataType["EVENT"] = "EVENT"; | ||
EventLogDataType["TOKEN_TRANSFER"] = "TOKEN_TRANSFER"; | ||
EventLogDataType["NATIVE_TOKEN_TRANSFER"] = "NATIVE_TOKEN_TRANSFER"; | ||
EventLogDataType["SEQUENCE_TXN"] = "SEQUENCE_TXN"; | ||
return EventLogDataType; | ||
}({}); | ||
let OrderStatus = /*#__PURE__*/function (OrderStatus) { | ||
OrderStatus["OPEN"] = "OPEN"; | ||
OrderStatus["CLOSED"] = "CLOSED"; | ||
OrderStatus["CANCELLED"] = "CANCELLED"; | ||
return OrderStatus; | ||
}({}); | ||
let TxnTransferType = /*#__PURE__*/function (TxnTransferType) { | ||
TxnTransferType["UNKNOWN"] = "UNKNOWN"; | ||
TxnTransferType["SEND"] = "SEND"; | ||
TxnTransferType["RECEIVE"] = "RECEIVE"; | ||
return TxnTransferType; | ||
}({}); | ||
let TransactionStatus = /*#__PURE__*/function (TransactionStatus) { | ||
TransactionStatus["FAILED"] = "FAILED"; | ||
TransactionStatus["SUCCESSFUL"] = "SUCCESSFUL"; | ||
return TransactionStatus; | ||
}({}); | ||
let TransactionType = /*#__PURE__*/function (TransactionType) { | ||
TransactionType["LegacyTxnType"] = "LegacyTxnType"; | ||
TransactionType["AccessListTxnType"] = "AccessListTxnType"; | ||
TransactionType["DynamicFeeTxnType"] = "DynamicFeeTxnType"; | ||
return TransactionType; | ||
}({}); | ||
let SortOrder = /*#__PURE__*/function (SortOrder) { | ||
SortOrder["DESC"] = "DESC"; | ||
SortOrder["ASC"] = "ASC"; | ||
return SortOrder; | ||
}({}); | ||
let ContractVerificationStatus = /*#__PURE__*/function (ContractVerificationStatus) { | ||
ContractVerificationStatus["VERIFIED"] = "VERIFIED"; | ||
ContractVerificationStatus["UNVERIFIED"] = "UNVERIFIED"; | ||
ContractVerificationStatus["ALL"] = "ALL"; | ||
return ContractVerificationStatus; | ||
}({}); | ||
// | ||
// Client | ||
// | ||
class IndexerGateway { | ||
constructor(hostname, fetch) { | ||
this.hostname = void 0; | ||
this.fetch = void 0; | ||
this.path = '/rpc/IndexerGateway/'; | ||
this.getNativeTokenBalance = (args, headers, signal) => { | ||
return this.fetch(this.url('GetNativeTokenBalance'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
balances: _data.balances | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.getTokenBalances = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalances'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: _data.page, | ||
balances: _data.balances | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.getTokenBalancesSummary = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalancesSummary'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: _data.page, | ||
balances: _data.balances | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.getTokenBalancesDetails = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalancesDetails'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: _data.page, | ||
balances: _data.balances | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.getTokenBalancesByContract = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalancesByContract'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: _data.page, | ||
balances: _data.balances | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.getBalanceUpdates = (args, headers, signal) => { | ||
return this.fetch(this.url('GetBalanceUpdates'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: _data.page, | ||
balances: _data.balances | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.ping = (headers, signal) => { | ||
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
status: _data.status | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.version = (headers, signal) => { | ||
return this.fetch(this.url('Version'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
version: _data.version | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.runtimeStatus = (headers, signal) => { | ||
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
status: _data.status | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.hostname = hostname.replace(/\/*$/, ''); | ||
this.fetch = (input, init) => fetch(input, init); | ||
} | ||
url(name) { | ||
return this.hostname + this.path + name; | ||
} | ||
} | ||
const createHTTPRequest = (body = {}, headers = {}, signal = null) => { | ||
const reqHeaders = _extends({}, headers, { | ||
'Content-Type': 'application/json' | ||
}); | ||
reqHeaders[WebrpcHeader] = WebrpcHeaderValue; | ||
return { | ||
method: 'POST', | ||
headers: reqHeaders, | ||
body: JSON.stringify(body || {}), | ||
signal | ||
}; | ||
}; | ||
const buildResponse = res => { | ||
@@ -838,4 +1366,82 @@ return res.text().then(text => { | ||
} | ||
class GeoblockedError extends WebrpcError { | ||
constructor(name = 'Geoblocked', code = 1006, message = 'Geoblocked region', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, GeoblockedError.prototype); | ||
} | ||
} | ||
class RateLimitedError extends WebrpcError { | ||
constructor(name = 'RateLimited', code = 1007, message = 'Rate-limited. Please slow down.', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, RateLimitedError.prototype); | ||
} | ||
} | ||
class ProjectNotFoundError extends WebrpcError { | ||
constructor(name = 'ProjectNotFound', code = 1100, message = 'Project not found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, ProjectNotFoundError.prototype); | ||
} | ||
} | ||
class AccessKeyNotFoundError extends WebrpcError { | ||
constructor(name = 'AccessKeyNotFound', code = 1101, message = 'Access key not found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, AccessKeyNotFoundError.prototype); | ||
} | ||
} | ||
class AccessKeyMismatchError extends WebrpcError { | ||
constructor(name = 'AccessKeyMismatch', code = 1102, message = 'Access key mismatch', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, AccessKeyMismatchError.prototype); | ||
} | ||
} | ||
class InvalidOriginError extends WebrpcError { | ||
constructor(name = 'InvalidOrigin', code = 1103, message = 'Invalid origin for Access Key', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, InvalidOriginError.prototype); | ||
} | ||
} | ||
class InvalidServiceError extends WebrpcError { | ||
constructor(name = 'InvalidService', code = 1104, message = 'Service not enabled for Access key', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, InvalidServiceError.prototype); | ||
} | ||
} | ||
class UnauthorizedUserError extends WebrpcError { | ||
constructor(name = 'UnauthorizedUser', code = 1105, message = 'Unauthorized user', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, UnauthorizedUserError.prototype); | ||
} | ||
} | ||
class QuotaExceededError extends WebrpcError { | ||
constructor(name = 'QuotaExceeded', code = 1200, message = 'Quota exceeded', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, QuotaExceededError.prototype); | ||
} | ||
} | ||
class RateLimitError extends WebrpcError { | ||
constructor(name = 'RateLimit', code = 1201, message = 'Rate limit exceeded', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, RateLimitError.prototype); | ||
} | ||
} | ||
class NoDefaultKeyError extends WebrpcError { | ||
constructor(name = 'NoDefaultKey', code = 1300, message = 'No default access key found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, NoDefaultKeyError.prototype); | ||
} | ||
} | ||
class MaxAccessKeysError extends WebrpcError { | ||
constructor(name = 'MaxAccessKeys', code = 1301, message = 'Access keys limit reached', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, MaxAccessKeysError.prototype); | ||
} | ||
} | ||
class AtLeastOneKeyError extends WebrpcError { | ||
constructor(name = 'AtLeastOneKey', code = 1302, message = 'You need at least one Access Key', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, AtLeastOneKeyError.prototype); | ||
} | ||
} | ||
class TimeoutError extends WebrpcError { | ||
constructor(name = 'Timeout', code = 2000, message = 'Request timed out', status = 0, cause) { | ||
constructor(name = 'Timeout', code = 1900, message = 'Request timed out', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
@@ -875,8 +1481,2 @@ Object.setPrototypeOf(this, TimeoutError.prototype); | ||
} | ||
class ProjectNotFoundError extends WebrpcError { | ||
constructor(name = 'ProjectNotFound', code = 3002, message = 'Project not found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, ProjectNotFoundError.prototype); | ||
} | ||
} | ||
class MetadataCallFailedError extends WebrpcError { | ||
@@ -906,2 +1506,15 @@ constructor(name = 'MetadataCallFailed', code = 3003, message = 'Metadata service call failed', status = 0, cause) { | ||
errors["Aborted"] = "Aborted"; | ||
errors["Geoblocked"] = "Geoblocked"; | ||
errors["RateLimited"] = "RateLimited"; | ||
errors["ProjectNotFound"] = "ProjectNotFound"; | ||
errors["AccessKeyNotFound"] = "AccessKeyNotFound"; | ||
errors["AccessKeyMismatch"] = "AccessKeyMismatch"; | ||
errors["InvalidOrigin"] = "InvalidOrigin"; | ||
errors["InvalidService"] = "InvalidService"; | ||
errors["UnauthorizedUser"] = "UnauthorizedUser"; | ||
errors["QuotaExceeded"] = "QuotaExceeded"; | ||
errors["RateLimit"] = "RateLimit"; | ||
errors["NoDefaultKey"] = "NoDefaultKey"; | ||
errors["MaxAccessKeys"] = "MaxAccessKeys"; | ||
errors["AtLeastOneKey"] = "AtLeastOneKey"; | ||
errors["Timeout"] = "Timeout"; | ||
@@ -913,3 +1526,2 @@ errors["InvalidArgument"] = "InvalidArgument"; | ||
errors["NotFound"] = "NotFound"; | ||
errors["ProjectNotFound"] = "ProjectNotFound"; | ||
errors["MetadataCallFailed"] = "MetadataCallFailed"; | ||
@@ -936,3 +1548,16 @@ return errors; | ||
[1005]: AbortedError, | ||
[2000]: TimeoutError, | ||
[1006]: GeoblockedError, | ||
[1007]: RateLimitedError, | ||
[1100]: ProjectNotFoundError, | ||
[1101]: AccessKeyNotFoundError, | ||
[1102]: AccessKeyMismatchError, | ||
[1103]: InvalidOriginError, | ||
[1104]: InvalidServiceError, | ||
[1105]: UnauthorizedUserError, | ||
[1200]: QuotaExceededError, | ||
[1201]: RateLimitError, | ||
[1300]: NoDefaultKeyError, | ||
[1301]: MaxAccessKeysError, | ||
[1302]: AtLeastOneKeyError, | ||
[1900]: TimeoutError, | ||
[2001]: InvalidArgumentError, | ||
@@ -943,6 +1568,64 @@ [2002]: UnavailableError, | ||
[3000]: NotFoundError, | ||
[3002]: ProjectNotFoundError, | ||
[3003]: MetadataCallFailedError | ||
}; | ||
var indexergw_gen = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
WebrpcHeader: WebrpcHeader, | ||
WebrpcHeaderValue: WebrpcHeaderValue, | ||
WebRPCVersion: WebRPCVersion, | ||
WebRPCSchemaVersion: WebRPCSchemaVersion, | ||
WebRPCSchemaHash: WebRPCSchemaHash, | ||
VersionFromHeader: VersionFromHeader, | ||
ContractType: ContractType, | ||
EventLogType: EventLogType, | ||
EventLogDataType: EventLogDataType, | ||
OrderStatus: OrderStatus, | ||
TxnTransferType: TxnTransferType, | ||
TransactionStatus: TransactionStatus, | ||
TransactionType: TransactionType, | ||
SortOrder: SortOrder, | ||
ContractVerificationStatus: ContractVerificationStatus, | ||
IndexerGateway: IndexerGateway, | ||
WebrpcError: WebrpcError, | ||
WebrpcEndpointError: WebrpcEndpointError, | ||
WebrpcRequestFailedError: WebrpcRequestFailedError, | ||
WebrpcBadRouteError: WebrpcBadRouteError, | ||
WebrpcBadMethodError: WebrpcBadMethodError, | ||
WebrpcBadRequestError: WebrpcBadRequestError, | ||
WebrpcBadResponseError: WebrpcBadResponseError, | ||
WebrpcServerPanicError: WebrpcServerPanicError, | ||
WebrpcInternalErrorError: WebrpcInternalErrorError, | ||
WebrpcClientDisconnectedError: WebrpcClientDisconnectedError, | ||
WebrpcStreamLostError: WebrpcStreamLostError, | ||
WebrpcStreamFinishedError: WebrpcStreamFinishedError, | ||
UnauthorizedError: UnauthorizedError, | ||
PermissionDeniedError: PermissionDeniedError, | ||
SessionExpiredError: SessionExpiredError, | ||
MethodNotFoundError: MethodNotFoundError, | ||
RequestConflictError: RequestConflictError, | ||
AbortedError: AbortedError, | ||
GeoblockedError: GeoblockedError, | ||
RateLimitedError: RateLimitedError, | ||
ProjectNotFoundError: ProjectNotFoundError, | ||
AccessKeyNotFoundError: AccessKeyNotFoundError, | ||
AccessKeyMismatchError: AccessKeyMismatchError, | ||
InvalidOriginError: InvalidOriginError, | ||
InvalidServiceError: InvalidServiceError, | ||
UnauthorizedUserError: UnauthorizedUserError, | ||
QuotaExceededError: QuotaExceededError, | ||
RateLimitError: RateLimitError, | ||
NoDefaultKeyError: NoDefaultKeyError, | ||
MaxAccessKeysError: MaxAccessKeysError, | ||
AtLeastOneKeyError: AtLeastOneKeyError, | ||
TimeoutError: TimeoutError, | ||
InvalidArgumentError: InvalidArgumentError, | ||
UnavailableError: UnavailableError, | ||
QueryFailedError: QueryFailedError, | ||
ResourceExhaustedError: ResourceExhaustedError, | ||
NotFoundError: NotFoundError, | ||
MetadataCallFailedError: MetadataCallFailedError, | ||
errors: errors | ||
}); | ||
class SequenceIndexer extends Indexer { | ||
@@ -973,43 +1656,70 @@ constructor(hostname, projectAccessKey, jwtAuth) { | ||
} | ||
class SequenceIndexerGateway extends IndexerGateway { | ||
constructor(hostname, projectAccessKey, jwtAuth) { | ||
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch); | ||
this.projectAccessKey = projectAccessKey; | ||
this.jwtAuth = jwtAuth; | ||
this._fetch = (input, init) => { | ||
// automatically include jwt and access key auth header to requests | ||
// if its been set on the api client | ||
const headers = {}; | ||
const jwtAuth = this.jwtAuth; | ||
const projectAccessKey = this.projectAccessKey; | ||
if (jwtAuth && jwtAuth.length > 0) { | ||
headers['Authorization'] = `BEARER ${jwtAuth}`; | ||
} | ||
if (projectAccessKey && projectAccessKey.length > 0) { | ||
headers['X-Access-Key'] = projectAccessKey; | ||
} | ||
exports.AbortedError = AbortedError; | ||
exports.ContractType = ContractType; | ||
exports.ContractVerificationStatus = ContractVerificationStatus; | ||
exports.EventLogDataType = EventLogDataType; | ||
exports.EventLogType = EventLogType; | ||
// before the request is made | ||
init.headers = _extends({}, init.headers, headers); | ||
return fetch(input, init); | ||
}; | ||
this.fetch = this._fetch; | ||
} | ||
} | ||
exports.AbortedError = AbortedError$1; | ||
exports.ContractType = ContractType$1; | ||
exports.ContractVerificationStatus = ContractVerificationStatus$1; | ||
exports.EventLogDataType = EventLogDataType$1; | ||
exports.EventLogType = EventLogType$1; | ||
exports.Indexer = Indexer; | ||
exports.InvalidArgumentError = InvalidArgumentError; | ||
exports.MetadataCallFailedError = MetadataCallFailedError; | ||
exports.MethodNotFoundError = MethodNotFoundError; | ||
exports.NotFoundError = NotFoundError; | ||
exports.OrderStatus = OrderStatus; | ||
exports.PermissionDeniedError = PermissionDeniedError; | ||
exports.ProjectNotFoundError = ProjectNotFoundError; | ||
exports.QueryFailedError = QueryFailedError; | ||
exports.RequestConflictError = RequestConflictError; | ||
exports.ResourceExhaustedError = ResourceExhaustedError; | ||
exports.IndexerGateway = indexergw_gen; | ||
exports.InvalidArgumentError = InvalidArgumentError$1; | ||
exports.MetadataCallFailedError = MetadataCallFailedError$1; | ||
exports.MethodNotFoundError = MethodNotFoundError$1; | ||
exports.NotFoundError = NotFoundError$1; | ||
exports.OrderStatus = OrderStatus$1; | ||
exports.PermissionDeniedError = PermissionDeniedError$1; | ||
exports.ProjectNotFoundError = ProjectNotFoundError$1; | ||
exports.QueryFailedError = QueryFailedError$1; | ||
exports.RequestConflictError = RequestConflictError$1; | ||
exports.ResourceExhaustedError = ResourceExhaustedError$1; | ||
exports.SequenceIndexer = SequenceIndexer; | ||
exports.SessionExpiredError = SessionExpiredError; | ||
exports.SortOrder = SortOrder; | ||
exports.TimeoutError = TimeoutError; | ||
exports.TransactionStatus = TransactionStatus; | ||
exports.TransactionType = TransactionType; | ||
exports.TxnTransferType = TxnTransferType; | ||
exports.UnauthorizedError = UnauthorizedError; | ||
exports.UnavailableError = UnavailableError; | ||
exports.WebRPCSchemaHash = WebRPCSchemaHash; | ||
exports.WebRPCSchemaVersion = WebRPCSchemaVersion; | ||
exports.WebRPCVersion = WebRPCVersion; | ||
exports.WebrpcBadMethodError = WebrpcBadMethodError; | ||
exports.WebrpcBadRequestError = WebrpcBadRequestError; | ||
exports.WebrpcBadResponseError = WebrpcBadResponseError; | ||
exports.WebrpcBadRouteError = WebrpcBadRouteError; | ||
exports.WebrpcClientDisconnectedError = WebrpcClientDisconnectedError; | ||
exports.WebrpcEndpointError = WebrpcEndpointError; | ||
exports.WebrpcError = WebrpcError; | ||
exports.WebrpcInternalErrorError = WebrpcInternalErrorError; | ||
exports.WebrpcRequestFailedError = WebrpcRequestFailedError; | ||
exports.WebrpcServerPanicError = WebrpcServerPanicError; | ||
exports.WebrpcStreamFinishedError = WebrpcStreamFinishedError; | ||
exports.WebrpcStreamLostError = WebrpcStreamLostError; | ||
exports.errors = errors; | ||
exports.SequenceIndexerGateway = SequenceIndexerGateway; | ||
exports.SessionExpiredError = SessionExpiredError$1; | ||
exports.SortOrder = SortOrder$1; | ||
exports.TimeoutError = TimeoutError$1; | ||
exports.TransactionStatus = TransactionStatus$1; | ||
exports.TransactionType = TransactionType$1; | ||
exports.TxnTransferType = TxnTransferType$1; | ||
exports.UnauthorizedError = UnauthorizedError$1; | ||
exports.UnavailableError = UnavailableError$1; | ||
exports.WebRPCSchemaHash = WebRPCSchemaHash$1; | ||
exports.WebRPCSchemaVersion = WebRPCSchemaVersion$1; | ||
exports.WebRPCVersion = WebRPCVersion$1; | ||
exports.WebrpcBadMethodError = WebrpcBadMethodError$1; | ||
exports.WebrpcBadRequestError = WebrpcBadRequestError$1; | ||
exports.WebrpcBadResponseError = WebrpcBadResponseError$1; | ||
exports.WebrpcBadRouteError = WebrpcBadRouteError$1; | ||
exports.WebrpcClientDisconnectedError = WebrpcClientDisconnectedError$1; | ||
exports.WebrpcEndpointError = WebrpcEndpointError$1; | ||
exports.WebrpcError = WebrpcError$1; | ||
exports.WebrpcInternalErrorError = WebrpcInternalErrorError$1; | ||
exports.WebrpcRequestFailedError = WebrpcRequestFailedError$1; | ||
exports.WebrpcServerPanicError = WebrpcServerPanicError$1; | ||
exports.WebrpcStreamFinishedError = WebrpcStreamFinishedError$1; | ||
exports.WebrpcStreamLostError = WebrpcStreamLostError$1; | ||
exports.errors = errors$1; |
@@ -19,9 +19,9 @@ function _extends() { | ||
// WebRPC description and code-gen version | ||
const WebRPCVersion = 'v1'; | ||
const WebRPCVersion$1 = 'v1'; | ||
// Schema version of your RIDL schema | ||
const WebRPCSchemaVersion = 'v0.4.0'; | ||
const WebRPCSchemaVersion$1 = 'v0.4.0'; | ||
// Schema hash generated from your RIDL schema | ||
const WebRPCSchemaHash = 'cae735346d8e5c3dce48dce9f85116989b6beffd'; | ||
const WebRPCSchemaHash$1 = 'cae735346d8e5c3dce48dce9f85116989b6beffd'; | ||
@@ -32,3 +32,3 @@ // | ||
let ContractType = /*#__PURE__*/function (ContractType) { | ||
let ContractType$1 = /*#__PURE__*/function (ContractType) { | ||
ContractType["UNKNOWN"] = "UNKNOWN"; | ||
@@ -46,3 +46,3 @@ ContractType["NATIVE"] = "NATIVE"; | ||
}({}); | ||
let EventLogType = /*#__PURE__*/function (EventLogType) { | ||
let EventLogType$1 = /*#__PURE__*/function (EventLogType) { | ||
EventLogType["UNKNOWN"] = "UNKNOWN"; | ||
@@ -53,3 +53,3 @@ EventLogType["BLOCK_ADDED"] = "BLOCK_ADDED"; | ||
}({}); | ||
let EventLogDataType = /*#__PURE__*/function (EventLogDataType) { | ||
let EventLogDataType$1 = /*#__PURE__*/function (EventLogDataType) { | ||
EventLogDataType["EVENT"] = "EVENT"; | ||
@@ -61,3 +61,3 @@ EventLogDataType["TOKEN_TRANSFER"] = "TOKEN_TRANSFER"; | ||
}({}); | ||
let OrderStatus = /*#__PURE__*/function (OrderStatus) { | ||
let OrderStatus$1 = /*#__PURE__*/function (OrderStatus) { | ||
OrderStatus["OPEN"] = "OPEN"; | ||
@@ -68,3 +68,3 @@ OrderStatus["CLOSED"] = "CLOSED"; | ||
}({}); | ||
let TxnTransferType = /*#__PURE__*/function (TxnTransferType) { | ||
let TxnTransferType$1 = /*#__PURE__*/function (TxnTransferType) { | ||
TxnTransferType["UNKNOWN"] = "UNKNOWN"; | ||
@@ -75,3 +75,3 @@ TxnTransferType["SEND"] = "SEND"; | ||
}({}); | ||
let TransactionStatus = /*#__PURE__*/function (TransactionStatus) { | ||
let TransactionStatus$1 = /*#__PURE__*/function (TransactionStatus) { | ||
TransactionStatus["FAILED"] = "FAILED"; | ||
@@ -81,3 +81,3 @@ TransactionStatus["SUCCESSFUL"] = "SUCCESSFUL"; | ||
}({}); | ||
let TransactionType = /*#__PURE__*/function (TransactionType) { | ||
let TransactionType$1 = /*#__PURE__*/function (TransactionType) { | ||
TransactionType["LegacyTxnType"] = "LegacyTxnType"; | ||
@@ -88,3 +88,3 @@ TransactionType["AccessListTxnType"] = "AccessListTxnType"; | ||
}({}); | ||
let SortOrder = /*#__PURE__*/function (SortOrder) { | ||
let SortOrder$1 = /*#__PURE__*/function (SortOrder) { | ||
SortOrder["DESC"] = "DESC"; | ||
@@ -94,3 +94,3 @@ SortOrder["ASC"] = "ASC"; | ||
}({}); | ||
let ContractVerificationStatus = /*#__PURE__*/function (ContractVerificationStatus) { | ||
let ContractVerificationStatus$1 = /*#__PURE__*/function (ContractVerificationStatus) { | ||
ContractVerificationStatus["VERIFIED"] = "VERIFIED"; | ||
@@ -110,4 +110,4 @@ ContractVerificationStatus["UNVERIFIED"] = "UNVERIFIED"; | ||
this.ping = (headers, signal) => { | ||
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('Ping'), createHTTPRequest$1({}, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -118,3 +118,3 @@ status: _data.status | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -125,4 +125,4 @@ }); | ||
this.version = (headers, signal) => { | ||
return this.fetch(this.url('Version'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('Version'), createHTTPRequest$1({}, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -133,3 +133,3 @@ version: _data.version | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -140,4 +140,4 @@ }); | ||
this.runtimeStatus = (headers, signal) => { | ||
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest$1({}, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -148,3 +148,3 @@ status: _data.status | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -155,4 +155,4 @@ }); | ||
this.getChainID = (headers, signal) => { | ||
return this.fetch(this.url('GetChainID'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetChainID'), createHTTPRequest$1({}, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -163,3 +163,3 @@ chainID: _data.chainID | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -170,4 +170,4 @@ }); | ||
this.getEtherBalance = (args, headers, signal) => { | ||
return this.fetch(this.url('GetEtherBalance'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetEtherBalance'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -178,3 +178,3 @@ balance: _data.balance | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -185,4 +185,4 @@ }); | ||
this.getNativeTokenBalance = (args, headers, signal) => { | ||
return this.fetch(this.url('GetNativeTokenBalance'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetNativeTokenBalance'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -193,3 +193,3 @@ balance: _data.balance | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -200,4 +200,4 @@ }); | ||
this.getTokenBalancesSummary = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalancesSummary'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTokenBalancesSummary'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -209,3 +209,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -216,4 +216,4 @@ }); | ||
this.getTokenBalancesDetails = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalancesDetails'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTokenBalancesDetails'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -225,3 +225,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -232,4 +232,4 @@ }); | ||
this.getTokenBalancesByContract = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalancesByContract'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTokenBalancesByContract'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -241,3 +241,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -248,4 +248,4 @@ }); | ||
this.getTokenBalances = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalances'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTokenBalances'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -257,3 +257,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -264,4 +264,4 @@ }); | ||
this.getTokenSupplies = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenSupplies'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTokenSupplies'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -274,3 +274,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -281,4 +281,4 @@ }); | ||
this.getTokenSuppliesMap = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenSuppliesMap'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTokenSuppliesMap'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -289,3 +289,3 @@ supplies: _data.supplies | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -296,4 +296,4 @@ }); | ||
this.getBalanceUpdates = (args, headers, signal) => { | ||
return this.fetch(this.url('GetBalanceUpdates'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetBalanceUpdates'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -305,3 +305,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -312,4 +312,4 @@ }); | ||
this.getTransactionHistory = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTransactionHistory'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTransactionHistory'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -321,3 +321,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -328,8 +328,8 @@ }); | ||
this.syncBalance = (args, headers, signal) => { | ||
return this.fetch(this.url('SyncBalance'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('SyncBalance'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return {}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -340,4 +340,4 @@ }); | ||
this.fetchTransactionReceipt = (args, headers, signal) => { | ||
return this.fetch(this.url('FetchTransactionReceipt'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('FetchTransactionReceipt'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -348,3 +348,3 @@ receipt: _data.receipt | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -355,4 +355,4 @@ }); | ||
this.getOrderbookOrders = (args, headers, signal) => { | ||
return this.fetch(this.url('GetOrderbookOrders'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetOrderbookOrders'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -364,3 +364,3 @@ page: _data.page, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -371,4 +371,4 @@ }); | ||
this.getTopOrders = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTopOrders'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetTopOrders'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -379,3 +379,3 @@ orders: _data.orders | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -386,4 +386,4 @@ }); | ||
this.fetchTransactionReceiptWithFilter = (args, headers, signal) => { | ||
return this.fetch(this.url('FetchTransactionReceiptWithFilter'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('FetchTransactionReceiptWithFilter'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -394,3 +394,3 @@ receipt: _data.receipt | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -401,4 +401,4 @@ }); | ||
this.getAllWebhookListeners = (args, headers, signal) => { | ||
return this.fetch(this.url('GetAllWebhookListeners'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetAllWebhookListeners'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -409,3 +409,3 @@ listeners: _data.listeners | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -416,4 +416,4 @@ }); | ||
this.getWebhookListener = (args, headers, signal) => { | ||
return this.fetch(this.url('GetWebhookListener'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('GetWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -424,3 +424,3 @@ listener: _data.listener | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -431,4 +431,4 @@ }); | ||
this.addWebhookListener = (args, headers, signal) => { | ||
return this.fetch(this.url('AddWebhookListener'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('AddWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -440,3 +440,3 @@ status: _data.status, | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -447,4 +447,4 @@ }); | ||
this.updateWebhookListener = (args, headers, signal) => { | ||
return this.fetch(this.url('UpdateWebhookListener'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('UpdateWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -455,3 +455,3 @@ status: _data.status | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -462,4 +462,4 @@ }); | ||
this.removeWebhookListener = (args, headers, signal) => { | ||
return this.fetch(this.url('RemoveWebhookListener'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('RemoveWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -470,3 +470,3 @@ status: _data.status | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -477,4 +477,4 @@ }); | ||
this.toggleWebhookListener = (args, headers, signal) => { | ||
return this.fetch(this.url('ToggleWebhookListener'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('ToggleWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -485,3 +485,3 @@ webhookListener: _data.webhookListener | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -492,4 +492,4 @@ }); | ||
this.pauseAllWebhookListeners = (args, headers, signal) => { | ||
return this.fetch(this.url('PauseAllWebhookListeners'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('PauseAllWebhookListeners'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -500,3 +500,3 @@ status: _data.status | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -507,4 +507,4 @@ }); | ||
this.resumeAllWebhookListeners = (args, headers, signal) => { | ||
return this.fetch(this.url('ResumeAllWebhookListeners'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return this.fetch(this.url('ResumeAllWebhookListeners'), createHTTPRequest$1(args, headers, signal)).then(res => { | ||
return buildResponse$1(res).then(_data => { | ||
return { | ||
@@ -515,3 +515,3 @@ status: _data.status | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
throw WebrpcRequestFailedError$1.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
@@ -522,3 +522,3 @@ }); | ||
this.subscribeReceipts = (args, options) => { | ||
const _fetch = () => this.fetch(this.url('SubscribeReceipts'), createHTTPRequest(args, options.headers, options.signal)).then(async function (res) { | ||
const _fetch = () => this.fetch(this.url('SubscribeReceipts'), createHTTPRequest$1(args, options.headers, options.signal)).then(async function (res) { | ||
await sseResponse(res, options, _fetch); | ||
@@ -531,3 +531,3 @@ }, error => { | ||
this.subscribeEvents = (args, options) => { | ||
const _fetch = () => this.fetch(this.url('SubscribeEvents'), createHTTPRequest(args, options.headers, options.signal)).then(async function (res) { | ||
const _fetch = () => this.fetch(this.url('SubscribeEvents'), createHTTPRequest$1(args, options.headers, options.signal)).then(async function (res) { | ||
await sseResponse(res, options, _fetch); | ||
@@ -540,3 +540,3 @@ }, error => { | ||
this.subscribeBalanceUpdates = (args, options) => { | ||
const _fetch = () => this.fetch(this.url('SubscribeBalanceUpdates'), createHTTPRequest(args, options.headers, options.signal)).then(async function (res) { | ||
const _fetch = () => this.fetch(this.url('SubscribeBalanceUpdates'), createHTTPRequest$1(args, options.headers, options.signal)).then(async function (res) { | ||
await sseResponse(res, options, _fetch); | ||
@@ -564,3 +564,3 @@ }, error => { | ||
try { | ||
await buildResponse(res); | ||
await buildResponse$1(res); | ||
} catch (error) { | ||
@@ -573,3 +573,3 @@ // @ts-ignore | ||
if (!res.body) { | ||
onError(WebrpcBadResponseError.new({ | ||
onError(WebrpcBadResponseError$1.new({ | ||
status: res.status, | ||
@@ -614,3 +614,3 @@ cause: 'Invalid response, missing body' | ||
if (error instanceof DOMException && error.name === 'AbortError') { | ||
onError(WebrpcRequestFailedError.new({ | ||
onError(WebrpcRequestFailedError$1.new({ | ||
message: 'AbortError', | ||
@@ -622,3 +622,3 @@ cause: `AbortError: ${message}` | ||
} else { | ||
onError(WebrpcStreamLostError.new({ | ||
onError(WebrpcStreamLostError$1.new({ | ||
cause: `reader.read(): ${message}` | ||
@@ -640,3 +640,3 @@ }), retryFetch); | ||
const code = typeof error.code === 'number' ? error.code : 0; | ||
onError((webrpcErrorByCode[code] || WebrpcError).new(error), retryFetch); | ||
onError((webrpcErrorByCode$1[code] || WebrpcError$1).new(error), retryFetch); | ||
return; | ||
@@ -648,3 +648,3 @@ } | ||
} | ||
onError(WebrpcBadResponseError.new({ | ||
onError(WebrpcBadResponseError$1.new({ | ||
status: res.status, | ||
@@ -665,3 +665,3 @@ // @ts-ignore | ||
}; | ||
const createHTTPRequest = (body = {}, headers = {}, signal = null) => { | ||
const createHTTPRequest$1 = (body = {}, headers = {}, signal = null) => { | ||
return { | ||
@@ -676,2 +676,530 @@ method: 'POST', | ||
}; | ||
const buildResponse$1 = res => { | ||
return res.text().then(text => { | ||
let data; | ||
try { | ||
data = JSON.parse(text); | ||
} catch (error) { | ||
let message = ''; | ||
if (error instanceof Error) { | ||
message = error.message; | ||
} | ||
throw WebrpcBadResponseError$1.new({ | ||
status: res.status, | ||
cause: `JSON.parse(): ${message}: response text: ${text}` | ||
}); | ||
} | ||
if (!res.ok) { | ||
const code = typeof data.code === 'number' ? data.code : 0; | ||
throw (webrpcErrorByCode$1[code] || WebrpcError$1).new(data); | ||
} | ||
return data; | ||
}); | ||
}; | ||
// | ||
// Errors | ||
// | ||
class WebrpcError$1 extends Error { | ||
constructor(name, code, message, status, cause) { | ||
super(message); | ||
this.name = void 0; | ||
this.code = void 0; | ||
this.message = void 0; | ||
this.status = void 0; | ||
this.cause = void 0; | ||
/** @deprecated Use message instead of msg. Deprecated in webrpc v0.11.0. */ | ||
this.msg = void 0; | ||
this.name = name || 'WebrpcError'; | ||
this.code = typeof code === 'number' ? code : 0; | ||
this.message = message || `endpoint error ${this.code}`; | ||
this.msg = this.message; | ||
this.status = typeof status === 'number' ? status : 0; | ||
this.cause = cause; | ||
Object.setPrototypeOf(this, WebrpcError$1.prototype); | ||
} | ||
static new(payload) { | ||
return new this(payload.error, payload.code, payload.message || payload.msg, payload.status, payload.cause); | ||
} | ||
} | ||
// Webrpc errors | ||
class WebrpcEndpointError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcEndpoint', code = 0, message = 'endpoint error', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcEndpointError$1.prototype); | ||
} | ||
} | ||
class WebrpcRequestFailedError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcRequestFailed', code = -1, message = 'request failed', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcRequestFailedError$1.prototype); | ||
} | ||
} | ||
class WebrpcBadRouteError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcBadRoute', code = -2, message = 'bad route', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcBadRouteError$1.prototype); | ||
} | ||
} | ||
class WebrpcBadMethodError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcBadMethod', code = -3, message = 'bad method', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcBadMethodError$1.prototype); | ||
} | ||
} | ||
class WebrpcBadRequestError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcBadRequest', code = -4, message = 'bad request', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcBadRequestError$1.prototype); | ||
} | ||
} | ||
class WebrpcBadResponseError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcBadResponse', code = -5, message = 'bad response', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcBadResponseError$1.prototype); | ||
} | ||
} | ||
class WebrpcServerPanicError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcServerPanic', code = -6, message = 'server panic', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcServerPanicError$1.prototype); | ||
} | ||
} | ||
class WebrpcInternalErrorError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcInternalError', code = -7, message = 'internal error', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcInternalErrorError$1.prototype); | ||
} | ||
} | ||
class WebrpcClientDisconnectedError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcClientDisconnected', code = -8, message = 'client disconnected', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcClientDisconnectedError$1.prototype); | ||
} | ||
} | ||
class WebrpcStreamLostError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcStreamLost', code = -9, message = 'stream lost', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcStreamLostError$1.prototype); | ||
} | ||
} | ||
class WebrpcStreamFinishedError$1 extends WebrpcError$1 { | ||
constructor(name = 'WebrpcStreamFinished', code = -10, message = 'stream finished', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, WebrpcStreamFinishedError$1.prototype); | ||
} | ||
} | ||
// Schema errors | ||
class UnauthorizedError$1 extends WebrpcError$1 { | ||
constructor(name = 'Unauthorized', code = 1000, message = 'Unauthorized access', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, UnauthorizedError$1.prototype); | ||
} | ||
} | ||
class PermissionDeniedError$1 extends WebrpcError$1 { | ||
constructor(name = 'PermissionDenied', code = 1001, message = 'Permission denied', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, PermissionDeniedError$1.prototype); | ||
} | ||
} | ||
class SessionExpiredError$1 extends WebrpcError$1 { | ||
constructor(name = 'SessionExpired', code = 1002, message = 'Session expired', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, SessionExpiredError$1.prototype); | ||
} | ||
} | ||
class MethodNotFoundError$1 extends WebrpcError$1 { | ||
constructor(name = 'MethodNotFound', code = 1003, message = 'Method not found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, MethodNotFoundError$1.prototype); | ||
} | ||
} | ||
class RequestConflictError$1 extends WebrpcError$1 { | ||
constructor(name = 'RequestConflict', code = 1004, message = 'Conflict with target resource', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, RequestConflictError$1.prototype); | ||
} | ||
} | ||
class AbortedError$1 extends WebrpcError$1 { | ||
constructor(name = 'Aborted', code = 1005, message = 'Request aborted', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, AbortedError$1.prototype); | ||
} | ||
} | ||
class TimeoutError$1 extends WebrpcError$1 { | ||
constructor(name = 'Timeout', code = 2000, message = 'Request timed out', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, TimeoutError$1.prototype); | ||
} | ||
} | ||
class InvalidArgumentError$1 extends WebrpcError$1 { | ||
constructor(name = 'InvalidArgument', code = 2001, message = 'Invalid argument', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, InvalidArgumentError$1.prototype); | ||
} | ||
} | ||
class UnavailableError$1 extends WebrpcError$1 { | ||
constructor(name = 'Unavailable', code = 2002, message = 'Unavailable resource', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, UnavailableError$1.prototype); | ||
} | ||
} | ||
class QueryFailedError$1 extends WebrpcError$1 { | ||
constructor(name = 'QueryFailed', code = 2003, message = 'Query failed', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, QueryFailedError$1.prototype); | ||
} | ||
} | ||
class ResourceExhaustedError$1 extends WebrpcError$1 { | ||
constructor(name = 'ResourceExhausted', code = 2004, message = 'Resource exhausted', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, ResourceExhaustedError$1.prototype); | ||
} | ||
} | ||
class NotFoundError$1 extends WebrpcError$1 { | ||
constructor(name = 'NotFound', code = 3000, message = 'Resource not found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, NotFoundError$1.prototype); | ||
} | ||
} | ||
class ProjectNotFoundError$1 extends WebrpcError$1 { | ||
constructor(name = 'ProjectNotFound', code = 3002, message = 'Project not found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, ProjectNotFoundError$1.prototype); | ||
} | ||
} | ||
class MetadataCallFailedError$1 extends WebrpcError$1 { | ||
constructor(name = 'MetadataCallFailed', code = 3003, message = 'Metadata service call failed', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, MetadataCallFailedError$1.prototype); | ||
} | ||
} | ||
let errors$1 = /*#__PURE__*/function (errors) { | ||
errors["WebrpcEndpoint"] = "WebrpcEndpoint"; | ||
errors["WebrpcRequestFailed"] = "WebrpcRequestFailed"; | ||
errors["WebrpcBadRoute"] = "WebrpcBadRoute"; | ||
errors["WebrpcBadMethod"] = "WebrpcBadMethod"; | ||
errors["WebrpcBadRequest"] = "WebrpcBadRequest"; | ||
errors["WebrpcBadResponse"] = "WebrpcBadResponse"; | ||
errors["WebrpcServerPanic"] = "WebrpcServerPanic"; | ||
errors["WebrpcInternalError"] = "WebrpcInternalError"; | ||
errors["WebrpcClientDisconnected"] = "WebrpcClientDisconnected"; | ||
errors["WebrpcStreamLost"] = "WebrpcStreamLost"; | ||
errors["WebrpcStreamFinished"] = "WebrpcStreamFinished"; | ||
errors["Unauthorized"] = "Unauthorized"; | ||
errors["PermissionDenied"] = "PermissionDenied"; | ||
errors["SessionExpired"] = "SessionExpired"; | ||
errors["MethodNotFound"] = "MethodNotFound"; | ||
errors["RequestConflict"] = "RequestConflict"; | ||
errors["Aborted"] = "Aborted"; | ||
errors["Timeout"] = "Timeout"; | ||
errors["InvalidArgument"] = "InvalidArgument"; | ||
errors["Unavailable"] = "Unavailable"; | ||
errors["QueryFailed"] = "QueryFailed"; | ||
errors["ResourceExhausted"] = "ResourceExhausted"; | ||
errors["NotFound"] = "NotFound"; | ||
errors["ProjectNotFound"] = "ProjectNotFound"; | ||
errors["MetadataCallFailed"] = "MetadataCallFailed"; | ||
return errors; | ||
}({}); | ||
const webrpcErrorByCode$1 = { | ||
[0]: WebrpcEndpointError$1, | ||
[-1]: WebrpcRequestFailedError$1, | ||
[-2]: WebrpcBadRouteError$1, | ||
[-3]: WebrpcBadMethodError$1, | ||
[-4]: WebrpcBadRequestError$1, | ||
[-5]: WebrpcBadResponseError$1, | ||
[-6]: WebrpcServerPanicError$1, | ||
[-7]: WebrpcInternalErrorError$1, | ||
[-8]: WebrpcClientDisconnectedError$1, | ||
[-9]: WebrpcStreamLostError$1, | ||
[-10]: WebrpcStreamFinishedError$1, | ||
[1000]: UnauthorizedError$1, | ||
[1001]: PermissionDeniedError$1, | ||
[1002]: SessionExpiredError$1, | ||
[1003]: MethodNotFoundError$1, | ||
[1004]: RequestConflictError$1, | ||
[1005]: AbortedError$1, | ||
[2000]: TimeoutError$1, | ||
[2001]: InvalidArgumentError$1, | ||
[2002]: UnavailableError$1, | ||
[2003]: QueryFailedError$1, | ||
[2004]: ResourceExhaustedError$1, | ||
[3000]: NotFoundError$1, | ||
[3002]: ProjectNotFoundError$1, | ||
[3003]: MetadataCallFailedError$1 | ||
}; | ||
/* eslint-disable */ | ||
// sequence-indexer v0.4.0 71cd081c5ca2372bf92a897ae1aa4ebf93ffd0fc | ||
// -- | ||
// Code generated by webrpc-gen@v0.21.1 with typescript generator. DO NOT EDIT. | ||
// | ||
// webrpc-gen -schema=indexer.ridl -service=IndexerGateway -target=typescript -client -out=./clients/indexergw/indexer.gen.ts | ||
const WebrpcHeader = "Webrpc"; | ||
const WebrpcHeaderValue = "webrpc@v0.21.1;gen-typescript@v0.15.1;sequence-indexer@v0.4.0"; | ||
// WebRPC description and code-gen version | ||
const WebRPCVersion = "v1"; | ||
// Schema version of your RIDL schema | ||
const WebRPCSchemaVersion = "v0.4.0"; | ||
// Schema hash generated from your RIDL schema | ||
const WebRPCSchemaHash = "71cd081c5ca2372bf92a897ae1aa4ebf93ffd0fc"; | ||
function VersionFromHeader(headers) { | ||
const headerValue = headers.get(WebrpcHeader); | ||
if (!headerValue) { | ||
return { | ||
webrpcGenVersion: "", | ||
codeGenName: "", | ||
codeGenVersion: "", | ||
schemaName: "", | ||
schemaVersion: "" | ||
}; | ||
} | ||
return parseWebrpcGenVersions(headerValue); | ||
} | ||
function parseWebrpcGenVersions(header) { | ||
const versions = header.split(";"); | ||
if (versions.length < 3) { | ||
return { | ||
webrpcGenVersion: "", | ||
codeGenName: "", | ||
codeGenVersion: "", | ||
schemaName: "", | ||
schemaVersion: "" | ||
}; | ||
} | ||
const [_, webrpcGenVersion] = versions[0].split("@"); | ||
const [codeGenName, codeGenVersion] = versions[1].split("@"); | ||
const [schemaName, schemaVersion] = versions[2].split("@"); | ||
return { | ||
webrpcGenVersion, | ||
codeGenName, | ||
codeGenVersion, | ||
schemaName, | ||
schemaVersion | ||
}; | ||
} | ||
// | ||
// Types | ||
// | ||
let ContractType = /*#__PURE__*/function (ContractType) { | ||
ContractType["UNKNOWN"] = "UNKNOWN"; | ||
ContractType["NATIVE"] = "NATIVE"; | ||
ContractType["ERC20"] = "ERC20"; | ||
ContractType["ERC721"] = "ERC721"; | ||
ContractType["ERC1155"] = "ERC1155"; | ||
ContractType["SEQUENCE_WALLET"] = "SEQUENCE_WALLET"; | ||
ContractType["ERC20_BRIDGE"] = "ERC20_BRIDGE"; | ||
ContractType["ERC721_BRIDGE"] = "ERC721_BRIDGE"; | ||
ContractType["ERC1155_BRIDGE"] = "ERC1155_BRIDGE"; | ||
ContractType["SEQ_MARKETPLACE"] = "SEQ_MARKETPLACE"; | ||
return ContractType; | ||
}({}); | ||
let EventLogType = /*#__PURE__*/function (EventLogType) { | ||
EventLogType["UNKNOWN"] = "UNKNOWN"; | ||
EventLogType["BLOCK_ADDED"] = "BLOCK_ADDED"; | ||
EventLogType["BLOCK_REMOVED"] = "BLOCK_REMOVED"; | ||
return EventLogType; | ||
}({}); | ||
let EventLogDataType = /*#__PURE__*/function (EventLogDataType) { | ||
EventLogDataType["EVENT"] = "EVENT"; | ||
EventLogDataType["TOKEN_TRANSFER"] = "TOKEN_TRANSFER"; | ||
EventLogDataType["NATIVE_TOKEN_TRANSFER"] = "NATIVE_TOKEN_TRANSFER"; | ||
EventLogDataType["SEQUENCE_TXN"] = "SEQUENCE_TXN"; | ||
return EventLogDataType; | ||
}({}); | ||
let OrderStatus = /*#__PURE__*/function (OrderStatus) { | ||
OrderStatus["OPEN"] = "OPEN"; | ||
OrderStatus["CLOSED"] = "CLOSED"; | ||
OrderStatus["CANCELLED"] = "CANCELLED"; | ||
return OrderStatus; | ||
}({}); | ||
let TxnTransferType = /*#__PURE__*/function (TxnTransferType) { | ||
TxnTransferType["UNKNOWN"] = "UNKNOWN"; | ||
TxnTransferType["SEND"] = "SEND"; | ||
TxnTransferType["RECEIVE"] = "RECEIVE"; | ||
return TxnTransferType; | ||
}({}); | ||
let TransactionStatus = /*#__PURE__*/function (TransactionStatus) { | ||
TransactionStatus["FAILED"] = "FAILED"; | ||
TransactionStatus["SUCCESSFUL"] = "SUCCESSFUL"; | ||
return TransactionStatus; | ||
}({}); | ||
let TransactionType = /*#__PURE__*/function (TransactionType) { | ||
TransactionType["LegacyTxnType"] = "LegacyTxnType"; | ||
TransactionType["AccessListTxnType"] = "AccessListTxnType"; | ||
TransactionType["DynamicFeeTxnType"] = "DynamicFeeTxnType"; | ||
return TransactionType; | ||
}({}); | ||
let SortOrder = /*#__PURE__*/function (SortOrder) { | ||
SortOrder["DESC"] = "DESC"; | ||
SortOrder["ASC"] = "ASC"; | ||
return SortOrder; | ||
}({}); | ||
let ContractVerificationStatus = /*#__PURE__*/function (ContractVerificationStatus) { | ||
ContractVerificationStatus["VERIFIED"] = "VERIFIED"; | ||
ContractVerificationStatus["UNVERIFIED"] = "UNVERIFIED"; | ||
ContractVerificationStatus["ALL"] = "ALL"; | ||
return ContractVerificationStatus; | ||
}({}); | ||
// | ||
// Client | ||
// | ||
class IndexerGateway { | ||
constructor(hostname, fetch) { | ||
this.hostname = void 0; | ||
this.fetch = void 0; | ||
this.path = '/rpc/IndexerGateway/'; | ||
this.getNativeTokenBalance = (args, headers, signal) => { | ||
return this.fetch(this.url('GetNativeTokenBalance'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
balances: _data.balances | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.getTokenBalances = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalances'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: _data.page, | ||
balances: _data.balances | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.getTokenBalancesSummary = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalancesSummary'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: _data.page, | ||
balances: _data.balances | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.getTokenBalancesDetails = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalancesDetails'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: _data.page, | ||
balances: _data.balances | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.getTokenBalancesByContract = (args, headers, signal) => { | ||
return this.fetch(this.url('GetTokenBalancesByContract'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: _data.page, | ||
balances: _data.balances | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.getBalanceUpdates = (args, headers, signal) => { | ||
return this.fetch(this.url('GetBalanceUpdates'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: _data.page, | ||
balances: _data.balances | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.ping = (headers, signal) => { | ||
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
status: _data.status | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.version = (headers, signal) => { | ||
return this.fetch(this.url('Version'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
version: _data.version | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.runtimeStatus = (headers, signal) => { | ||
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
status: _data.status | ||
}; | ||
}); | ||
}, error => { | ||
throw WebrpcRequestFailedError.new({ | ||
cause: `fetch(): ${error.message || ''}` | ||
}); | ||
}); | ||
}; | ||
this.hostname = hostname.replace(/\/*$/, ''); | ||
this.fetch = (input, init) => fetch(input, init); | ||
} | ||
url(name) { | ||
return this.hostname + this.path + name; | ||
} | ||
} | ||
const createHTTPRequest = (body = {}, headers = {}, signal = null) => { | ||
const reqHeaders = _extends({}, headers, { | ||
'Content-Type': 'application/json' | ||
}); | ||
reqHeaders[WebrpcHeader] = WebrpcHeaderValue; | ||
return { | ||
method: 'POST', | ||
headers: reqHeaders, | ||
body: JSON.stringify(body || {}), | ||
signal | ||
}; | ||
}; | ||
const buildResponse = res => { | ||
@@ -834,4 +1362,82 @@ return res.text().then(text => { | ||
} | ||
class GeoblockedError extends WebrpcError { | ||
constructor(name = 'Geoblocked', code = 1006, message = 'Geoblocked region', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, GeoblockedError.prototype); | ||
} | ||
} | ||
class RateLimitedError extends WebrpcError { | ||
constructor(name = 'RateLimited', code = 1007, message = 'Rate-limited. Please slow down.', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, RateLimitedError.prototype); | ||
} | ||
} | ||
class ProjectNotFoundError extends WebrpcError { | ||
constructor(name = 'ProjectNotFound', code = 1100, message = 'Project not found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, ProjectNotFoundError.prototype); | ||
} | ||
} | ||
class AccessKeyNotFoundError extends WebrpcError { | ||
constructor(name = 'AccessKeyNotFound', code = 1101, message = 'Access key not found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, AccessKeyNotFoundError.prototype); | ||
} | ||
} | ||
class AccessKeyMismatchError extends WebrpcError { | ||
constructor(name = 'AccessKeyMismatch', code = 1102, message = 'Access key mismatch', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, AccessKeyMismatchError.prototype); | ||
} | ||
} | ||
class InvalidOriginError extends WebrpcError { | ||
constructor(name = 'InvalidOrigin', code = 1103, message = 'Invalid origin for Access Key', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, InvalidOriginError.prototype); | ||
} | ||
} | ||
class InvalidServiceError extends WebrpcError { | ||
constructor(name = 'InvalidService', code = 1104, message = 'Service not enabled for Access key', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, InvalidServiceError.prototype); | ||
} | ||
} | ||
class UnauthorizedUserError extends WebrpcError { | ||
constructor(name = 'UnauthorizedUser', code = 1105, message = 'Unauthorized user', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, UnauthorizedUserError.prototype); | ||
} | ||
} | ||
class QuotaExceededError extends WebrpcError { | ||
constructor(name = 'QuotaExceeded', code = 1200, message = 'Quota exceeded', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, QuotaExceededError.prototype); | ||
} | ||
} | ||
class RateLimitError extends WebrpcError { | ||
constructor(name = 'RateLimit', code = 1201, message = 'Rate limit exceeded', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, RateLimitError.prototype); | ||
} | ||
} | ||
class NoDefaultKeyError extends WebrpcError { | ||
constructor(name = 'NoDefaultKey', code = 1300, message = 'No default access key found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, NoDefaultKeyError.prototype); | ||
} | ||
} | ||
class MaxAccessKeysError extends WebrpcError { | ||
constructor(name = 'MaxAccessKeys', code = 1301, message = 'Access keys limit reached', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, MaxAccessKeysError.prototype); | ||
} | ||
} | ||
class AtLeastOneKeyError extends WebrpcError { | ||
constructor(name = 'AtLeastOneKey', code = 1302, message = 'You need at least one Access Key', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, AtLeastOneKeyError.prototype); | ||
} | ||
} | ||
class TimeoutError extends WebrpcError { | ||
constructor(name = 'Timeout', code = 2000, message = 'Request timed out', status = 0, cause) { | ||
constructor(name = 'Timeout', code = 1900, message = 'Request timed out', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
@@ -871,8 +1477,2 @@ Object.setPrototypeOf(this, TimeoutError.prototype); | ||
} | ||
class ProjectNotFoundError extends WebrpcError { | ||
constructor(name = 'ProjectNotFound', code = 3002, message = 'Project not found', status = 0, cause) { | ||
super(name, code, message, status, cause); | ||
Object.setPrototypeOf(this, ProjectNotFoundError.prototype); | ||
} | ||
} | ||
class MetadataCallFailedError extends WebrpcError { | ||
@@ -902,2 +1502,15 @@ constructor(name = 'MetadataCallFailed', code = 3003, message = 'Metadata service call failed', status = 0, cause) { | ||
errors["Aborted"] = "Aborted"; | ||
errors["Geoblocked"] = "Geoblocked"; | ||
errors["RateLimited"] = "RateLimited"; | ||
errors["ProjectNotFound"] = "ProjectNotFound"; | ||
errors["AccessKeyNotFound"] = "AccessKeyNotFound"; | ||
errors["AccessKeyMismatch"] = "AccessKeyMismatch"; | ||
errors["InvalidOrigin"] = "InvalidOrigin"; | ||
errors["InvalidService"] = "InvalidService"; | ||
errors["UnauthorizedUser"] = "UnauthorizedUser"; | ||
errors["QuotaExceeded"] = "QuotaExceeded"; | ||
errors["RateLimit"] = "RateLimit"; | ||
errors["NoDefaultKey"] = "NoDefaultKey"; | ||
errors["MaxAccessKeys"] = "MaxAccessKeys"; | ||
errors["AtLeastOneKey"] = "AtLeastOneKey"; | ||
errors["Timeout"] = "Timeout"; | ||
@@ -909,3 +1522,2 @@ errors["InvalidArgument"] = "InvalidArgument"; | ||
errors["NotFound"] = "NotFound"; | ||
errors["ProjectNotFound"] = "ProjectNotFound"; | ||
errors["MetadataCallFailed"] = "MetadataCallFailed"; | ||
@@ -932,3 +1544,16 @@ return errors; | ||
[1005]: AbortedError, | ||
[2000]: TimeoutError, | ||
[1006]: GeoblockedError, | ||
[1007]: RateLimitedError, | ||
[1100]: ProjectNotFoundError, | ||
[1101]: AccessKeyNotFoundError, | ||
[1102]: AccessKeyMismatchError, | ||
[1103]: InvalidOriginError, | ||
[1104]: InvalidServiceError, | ||
[1105]: UnauthorizedUserError, | ||
[1200]: QuotaExceededError, | ||
[1201]: RateLimitError, | ||
[1300]: NoDefaultKeyError, | ||
[1301]: MaxAccessKeysError, | ||
[1302]: AtLeastOneKeyError, | ||
[1900]: TimeoutError, | ||
[2001]: InvalidArgumentError, | ||
@@ -939,6 +1564,64 @@ [2002]: UnavailableError, | ||
[3000]: NotFoundError, | ||
[3002]: ProjectNotFoundError, | ||
[3003]: MetadataCallFailedError | ||
}; | ||
var indexergw_gen = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
WebrpcHeader: WebrpcHeader, | ||
WebrpcHeaderValue: WebrpcHeaderValue, | ||
WebRPCVersion: WebRPCVersion, | ||
WebRPCSchemaVersion: WebRPCSchemaVersion, | ||
WebRPCSchemaHash: WebRPCSchemaHash, | ||
VersionFromHeader: VersionFromHeader, | ||
ContractType: ContractType, | ||
EventLogType: EventLogType, | ||
EventLogDataType: EventLogDataType, | ||
OrderStatus: OrderStatus, | ||
TxnTransferType: TxnTransferType, | ||
TransactionStatus: TransactionStatus, | ||
TransactionType: TransactionType, | ||
SortOrder: SortOrder, | ||
ContractVerificationStatus: ContractVerificationStatus, | ||
IndexerGateway: IndexerGateway, | ||
WebrpcError: WebrpcError, | ||
WebrpcEndpointError: WebrpcEndpointError, | ||
WebrpcRequestFailedError: WebrpcRequestFailedError, | ||
WebrpcBadRouteError: WebrpcBadRouteError, | ||
WebrpcBadMethodError: WebrpcBadMethodError, | ||
WebrpcBadRequestError: WebrpcBadRequestError, | ||
WebrpcBadResponseError: WebrpcBadResponseError, | ||
WebrpcServerPanicError: WebrpcServerPanicError, | ||
WebrpcInternalErrorError: WebrpcInternalErrorError, | ||
WebrpcClientDisconnectedError: WebrpcClientDisconnectedError, | ||
WebrpcStreamLostError: WebrpcStreamLostError, | ||
WebrpcStreamFinishedError: WebrpcStreamFinishedError, | ||
UnauthorizedError: UnauthorizedError, | ||
PermissionDeniedError: PermissionDeniedError, | ||
SessionExpiredError: SessionExpiredError, | ||
MethodNotFoundError: MethodNotFoundError, | ||
RequestConflictError: RequestConflictError, | ||
AbortedError: AbortedError, | ||
GeoblockedError: GeoblockedError, | ||
RateLimitedError: RateLimitedError, | ||
ProjectNotFoundError: ProjectNotFoundError, | ||
AccessKeyNotFoundError: AccessKeyNotFoundError, | ||
AccessKeyMismatchError: AccessKeyMismatchError, | ||
InvalidOriginError: InvalidOriginError, | ||
InvalidServiceError: InvalidServiceError, | ||
UnauthorizedUserError: UnauthorizedUserError, | ||
QuotaExceededError: QuotaExceededError, | ||
RateLimitError: RateLimitError, | ||
NoDefaultKeyError: NoDefaultKeyError, | ||
MaxAccessKeysError: MaxAccessKeysError, | ||
AtLeastOneKeyError: AtLeastOneKeyError, | ||
TimeoutError: TimeoutError, | ||
InvalidArgumentError: InvalidArgumentError, | ||
UnavailableError: UnavailableError, | ||
QueryFailedError: QueryFailedError, | ||
ResourceExhaustedError: ResourceExhaustedError, | ||
NotFoundError: NotFoundError, | ||
MetadataCallFailedError: MetadataCallFailedError, | ||
errors: errors | ||
}); | ||
class SequenceIndexer extends Indexer { | ||
@@ -969,3 +1652,28 @@ constructor(hostname, projectAccessKey, jwtAuth) { | ||
} | ||
class SequenceIndexerGateway extends IndexerGateway { | ||
constructor(hostname, projectAccessKey, jwtAuth) { | ||
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch); | ||
this.projectAccessKey = projectAccessKey; | ||
this.jwtAuth = jwtAuth; | ||
this._fetch = (input, init) => { | ||
// automatically include jwt and access key auth header to requests | ||
// if its been set on the api client | ||
const headers = {}; | ||
const jwtAuth = this.jwtAuth; | ||
const projectAccessKey = this.projectAccessKey; | ||
if (jwtAuth && jwtAuth.length > 0) { | ||
headers['Authorization'] = `BEARER ${jwtAuth}`; | ||
} | ||
if (projectAccessKey && projectAccessKey.length > 0) { | ||
headers['X-Access-Key'] = projectAccessKey; | ||
} | ||
export { AbortedError, ContractType, ContractVerificationStatus, EventLogDataType, EventLogType, Indexer, InvalidArgumentError, MetadataCallFailedError, MethodNotFoundError, NotFoundError, OrderStatus, PermissionDeniedError, ProjectNotFoundError, QueryFailedError, RequestConflictError, ResourceExhaustedError, SequenceIndexer, SessionExpiredError, SortOrder, TimeoutError, TransactionStatus, TransactionType, TxnTransferType, UnauthorizedError, UnavailableError, WebRPCSchemaHash, WebRPCSchemaVersion, WebRPCVersion, WebrpcBadMethodError, WebrpcBadRequestError, WebrpcBadResponseError, WebrpcBadRouteError, WebrpcClientDisconnectedError, WebrpcEndpointError, WebrpcError, WebrpcInternalErrorError, WebrpcRequestFailedError, WebrpcServerPanicError, WebrpcStreamFinishedError, WebrpcStreamLostError, errors }; | ||
// before the request is made | ||
init.headers = _extends({}, init.headers, headers); | ||
return fetch(input, init); | ||
}; | ||
this.fetch = this._fetch; | ||
} | ||
} | ||
export { AbortedError$1 as AbortedError, ContractType$1 as ContractType, ContractVerificationStatus$1 as ContractVerificationStatus, EventLogDataType$1 as EventLogDataType, EventLogType$1 as EventLogType, Indexer, indexergw_gen as IndexerGateway, InvalidArgumentError$1 as InvalidArgumentError, MetadataCallFailedError$1 as MetadataCallFailedError, MethodNotFoundError$1 as MethodNotFoundError, NotFoundError$1 as NotFoundError, OrderStatus$1 as OrderStatus, PermissionDeniedError$1 as PermissionDeniedError, ProjectNotFoundError$1 as ProjectNotFoundError, QueryFailedError$1 as QueryFailedError, RequestConflictError$1 as RequestConflictError, ResourceExhaustedError$1 as ResourceExhaustedError, SequenceIndexer, SequenceIndexerGateway, SessionExpiredError$1 as SessionExpiredError, SortOrder$1 as SortOrder, TimeoutError$1 as TimeoutError, TransactionStatus$1 as TransactionStatus, TransactionType$1 as TransactionType, TxnTransferType$1 as TxnTransferType, UnauthorizedError$1 as UnauthorizedError, UnavailableError$1 as UnavailableError, WebRPCSchemaHash$1 as WebRPCSchemaHash, WebRPCSchemaVersion$1 as WebRPCSchemaVersion, WebRPCVersion$1 as WebRPCVersion, WebrpcBadMethodError$1 as WebrpcBadMethodError, WebrpcBadRequestError$1 as WebrpcBadRequestError, WebrpcBadResponseError$1 as WebrpcBadResponseError, WebrpcBadRouteError$1 as WebrpcBadRouteError, WebrpcClientDisconnectedError$1 as WebrpcClientDisconnectedError, WebrpcEndpointError$1 as WebrpcEndpointError, WebrpcError$1 as WebrpcError, WebrpcInternalErrorError$1 as WebrpcInternalErrorError, WebrpcRequestFailedError$1 as WebrpcRequestFailedError, WebrpcServerPanicError$1 as WebrpcServerPanicError, WebrpcStreamFinishedError$1 as WebrpcStreamFinishedError, WebrpcStreamLostError$1 as WebrpcStreamLostError, errors$1 as errors }; |
export * from "./indexer.gen.js"; | ||
export * as IndexerGateway from "./indexergw.gen.js"; | ||
import { Indexer as IndexerRpc } from "./indexer.gen.js"; | ||
import { IndexerGateway as IndexerGatewayRpc } from "./indexergw.gen.js"; | ||
export declare class SequenceIndexer extends IndexerRpc { | ||
@@ -9,1 +11,7 @@ projectAccessKey?: string | undefined; | ||
} | ||
export declare class SequenceIndexerGateway extends IndexerGatewayRpc { | ||
projectAccessKey?: string | undefined; | ||
jwtAuth?: string | undefined; | ||
constructor(hostname: string, projectAccessKey?: string | undefined, jwtAuth?: string | undefined); | ||
_fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>; | ||
} |
{ | ||
"name": "@0xsequence/indexer", | ||
"version": "2.1.8", | ||
"version": "2.2.0", | ||
"description": "indexer sub-package for Sequence", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/indexer", |
export * from './indexer.gen' | ||
export * as IndexerGateway from './indexergw.gen' | ||
import { Indexer as IndexerRpc } from './indexer.gen' | ||
import { IndexerGateway as IndexerGatewayRpc } from './indexergw.gen' | ||
@@ -37,1 +39,34 @@ export class SequenceIndexer extends IndexerRpc { | ||
} | ||
export class SequenceIndexerGateway extends IndexerGatewayRpc { | ||
constructor( | ||
hostname: string, | ||
public projectAccessKey?: string, | ||
public jwtAuth?: string | ||
) { | ||
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch) | ||
this.fetch = this._fetch | ||
} | ||
_fetch = (input: RequestInfo, init?: RequestInit): Promise<Response> => { | ||
// automatically include jwt and access key auth header to requests | ||
// if its been set on the api client | ||
const headers: { [key: string]: any } = {} | ||
const jwtAuth = this.jwtAuth | ||
const projectAccessKey = this.projectAccessKey | ||
if (jwtAuth && jwtAuth.length > 0) { | ||
headers['Authorization'] = `BEARER ${jwtAuth}` | ||
} | ||
if (projectAccessKey && projectAccessKey.length > 0) { | ||
headers['X-Access-Key'] = projectAccessKey | ||
} | ||
// before the request is made | ||
init!.headers = { ...init!.headers, ...headers } | ||
return fetch(input, init) | ||
} | ||
} |
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
335575
14
9435
18