@0xsequence/indexer
Advanced tools
Comparing version 0.0.0-20241007154931 to 0.0.0-20241107182529
@@ -1,2 +0,2 @@ | ||
export * from "./declarations/src/index"; | ||
export * from "./declarations/src/index.js"; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMHhzZXF1ZW5jZS1pbmRleGVyLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi9kZWNsYXJhdGlvbnMvc3JjL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ== |
@@ -6,20 +6,15 @@ 'use strict'; | ||
function _extends() { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
return _extends = Object.assign ? Object.assign.bind() : function (n) { | ||
for (var e = 1; e < arguments.length; e++) { | ||
var t = arguments[e]; | ||
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
return n; | ||
}, _extends.apply(null, arguments); | ||
} | ||
/* eslint-disable */ | ||
// sequence-indexer v0.4.0 9accea267e7db3d66f40d5e0f27db92eb5a29e2f | ||
// sequence-indexer v0.4.0 cae735346d8e5c3dce48dce9f85116989b6beffd | ||
// -- | ||
// Code generated by webrpc-gen@v0.18.6 with typescript generator. DO NOT EDIT. | ||
// Code generated by webrpc-gen@v0.20.3 with typescript generator. DO NOT EDIT. | ||
// | ||
@@ -35,3 +30,3 @@ // webrpc-gen -schema=indexer.ridl -target=typescript -client -out=./clients/indexer.gen.ts | ||
// Schema hash generated from your RIDL schema | ||
const WebRPCSchemaHash = '9accea267e7db3d66f40d5e0f27db92eb5a29e2f'; | ||
const WebRPCSchemaHash = 'cae735346d8e5c3dce48dce9f85116989b6beffd'; | ||
@@ -96,2 +91,8 @@ // | ||
}({}); | ||
let ContractVerificationStatus = /*#__PURE__*/function (ContractVerificationStatus) { | ||
ContractVerificationStatus["VERIFIED"] = "VERIFIED"; | ||
ContractVerificationStatus["UNVERIFIED"] = "UNVERIFIED"; | ||
ContractVerificationStatus["ALL"] = "ALL"; | ||
return ContractVerificationStatus; | ||
}({}); | ||
// | ||
@@ -170,2 +171,57 @@ // Client | ||
}; | ||
this.getNativeTokenBalance = (args, headers, signal) => { | ||
return this.fetch(this.url('GetNativeTokenBalance'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
balance: _data.balance | ||
}; | ||
}); | ||
}, 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.getTokenBalances = (args, headers, signal) => { | ||
@@ -434,3 +490,3 @@ return this.fetch(this.url('GetTokenBalances'), createHTTPRequest(args, headers, signal)).then(res => { | ||
}; | ||
this.hostname = hostname; | ||
this.hostname = hostname.replace(/\/*$/, ''); | ||
this.fetch = (input, init) => fetch(input, init); | ||
@@ -471,85 +527,75 @@ } | ||
const timeout = (10 + 1) * 1000; | ||
let intervalId; | ||
try { | ||
intervalId = setInterval(() => { | ||
if (Date.now() - lastReadTime > timeout) { | ||
throw WebrpcStreamLostError.new({ | ||
cause: 'Stream timed out' | ||
let timeoutError = false; | ||
const intervalId = setInterval(() => { | ||
if (Date.now() - lastReadTime > timeout) { | ||
timeoutError = true; | ||
clearInterval(intervalId); | ||
reader.releaseLock(); | ||
} | ||
}, timeout); | ||
while (true) { | ||
let value; | ||
let done; | ||
try { | ||
; | ||
({ | ||
value, | ||
done | ||
} = await reader.read()); | ||
if (timeoutError) throw new Error('Timeout, no data or heartbeat received'); | ||
lastReadTime = Date.now(); | ||
buffer += decoder.decode(value, { | ||
stream: true | ||
}); | ||
} catch (error) { | ||
let message = ''; | ||
if (error instanceof Error) { | ||
message = error.message; | ||
} | ||
if (error instanceof DOMException && error.name === 'AbortError') { | ||
onError(WebrpcRequestFailedError.new({ | ||
message: 'AbortError', | ||
cause: `AbortError: ${message}` | ||
}), () => { | ||
throw new Error('Abort signal cannot be used to reconnect'); | ||
}); | ||
} else { | ||
onError(WebrpcStreamLostError.new({ | ||
cause: `reader.read(): ${message}` | ||
}), retryFetch); | ||
} | ||
}, timeout); | ||
while (true) { | ||
let value; | ||
let done; | ||
return; | ||
} | ||
let lines = buffer.split('\n'); | ||
for (let i = 0; i < lines.length - 1; i++) { | ||
if (lines[i].length == 0) { | ||
continue; | ||
} | ||
let data; | ||
try { | ||
; | ||
({ | ||
value, | ||
done | ||
} = await reader.read()); | ||
lastReadTime = Date.now(); | ||
buffer += decoder.decode(value, { | ||
stream: true | ||
}); | ||
data = JSON.parse(lines[i]); | ||
if (data.hasOwnProperty('webrpcError')) { | ||
const error = data.webrpcError; | ||
const code = typeof error.code === 'number' ? error.code : 0; | ||
onError((webrpcErrorByCode[code] || WebrpcError).new(error), retryFetch); | ||
return; | ||
} | ||
} catch (error) { | ||
let message = ''; | ||
if (error instanceof Error) { | ||
message = error.message; | ||
if (error instanceof Error && error.message === 'Abort signal cannot be used to reconnect') { | ||
throw error; | ||
} | ||
if (error instanceof DOMException && error.name === 'AbortError') { | ||
onError(WebrpcRequestFailedError.new({ | ||
message: 'AbortError', | ||
cause: `AbortError: ${message}` | ||
}), () => { | ||
throw new Error('Abort signal cannot be used to reconnect'); | ||
}); | ||
} else { | ||
onError(WebrpcStreamLostError.new({ | ||
cause: `reader.read(): ${message}` | ||
}), retryFetch); | ||
} | ||
return; | ||
onError(WebrpcBadResponseError.new({ | ||
status: res.status, | ||
// @ts-ignore | ||
cause: `JSON.parse(): ${error.message}` | ||
}), retryFetch); | ||
} | ||
let lines = buffer.split('\n'); | ||
for (let i = 0; i < lines.length - 1; i++) { | ||
if (lines[i].length == 0) { | ||
continue; | ||
} | ||
let data; | ||
try { | ||
data = JSON.parse(lines[i]); | ||
if (data.hasOwnProperty('webrpcError')) { | ||
const error = data.webrpcError; | ||
const code = typeof error.code === 'number' ? error.code : 0; | ||
onError((webrpcErrorByCode[code] || WebrpcError).new(error), retryFetch); | ||
return; | ||
} | ||
} catch (error) { | ||
if (error instanceof Error && error.message === 'Abort signal cannot be used to reconnect') { | ||
throw error; | ||
} | ||
onError(WebrpcBadResponseError.new({ | ||
status: res.status, | ||
// @ts-ignore | ||
cause: `JSON.parse(): ${error.message}` | ||
}), retryFetch); | ||
} | ||
onMessage(data); | ||
} | ||
if (!done) { | ||
buffer = lines[lines.length - 1]; | ||
continue; | ||
} | ||
onClose && onClose(); | ||
return; | ||
onMessage(data); | ||
} | ||
} catch (error) { | ||
// @ts-ignore | ||
if (error instanceof WebrpcStreamLostError) { | ||
onError(error, retryFetch); | ||
} else { | ||
throw error; | ||
if (!done) { | ||
buffer = lines[lines.length - 1]; | ||
continue; | ||
} | ||
} finally { | ||
clearInterval(intervalId); | ||
onClose && onClose(); | ||
return; | ||
} | ||
@@ -857,2 +903,3 @@ }; | ||
exports.ContractType = ContractType; | ||
exports.ContractVerificationStatus = ContractVerificationStatus; | ||
exports.EventLogDataType = EventLogDataType; | ||
@@ -859,0 +906,0 @@ exports.EventLogType = EventLogType; |
@@ -6,20 +6,15 @@ 'use strict'; | ||
function _extends() { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
return _extends = Object.assign ? Object.assign.bind() : function (n) { | ||
for (var e = 1; e < arguments.length; e++) { | ||
var t = arguments[e]; | ||
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
return n; | ||
}, _extends.apply(null, arguments); | ||
} | ||
/* eslint-disable */ | ||
// sequence-indexer v0.4.0 9accea267e7db3d66f40d5e0f27db92eb5a29e2f | ||
// sequence-indexer v0.4.0 cae735346d8e5c3dce48dce9f85116989b6beffd | ||
// -- | ||
// Code generated by webrpc-gen@v0.18.6 with typescript generator. DO NOT EDIT. | ||
// Code generated by webrpc-gen@v0.20.3 with typescript generator. DO NOT EDIT. | ||
// | ||
@@ -35,3 +30,3 @@ // webrpc-gen -schema=indexer.ridl -target=typescript -client -out=./clients/indexer.gen.ts | ||
// Schema hash generated from your RIDL schema | ||
const WebRPCSchemaHash = '9accea267e7db3d66f40d5e0f27db92eb5a29e2f'; | ||
const WebRPCSchemaHash = 'cae735346d8e5c3dce48dce9f85116989b6beffd'; | ||
@@ -96,2 +91,8 @@ // | ||
}({}); | ||
let ContractVerificationStatus = /*#__PURE__*/function (ContractVerificationStatus) { | ||
ContractVerificationStatus["VERIFIED"] = "VERIFIED"; | ||
ContractVerificationStatus["UNVERIFIED"] = "UNVERIFIED"; | ||
ContractVerificationStatus["ALL"] = "ALL"; | ||
return ContractVerificationStatus; | ||
}({}); | ||
// | ||
@@ -170,2 +171,57 @@ // Client | ||
}; | ||
this.getNativeTokenBalance = (args, headers, signal) => { | ||
return this.fetch(this.url('GetNativeTokenBalance'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
balance: _data.balance | ||
}; | ||
}); | ||
}, 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.getTokenBalances = (args, headers, signal) => { | ||
@@ -434,3 +490,3 @@ return this.fetch(this.url('GetTokenBalances'), createHTTPRequest(args, headers, signal)).then(res => { | ||
}; | ||
this.hostname = hostname; | ||
this.hostname = hostname.replace(/\/*$/, ''); | ||
this.fetch = (input, init) => fetch(input, init); | ||
@@ -471,85 +527,75 @@ } | ||
const timeout = (10 + 1) * 1000; | ||
let intervalId; | ||
try { | ||
intervalId = setInterval(() => { | ||
if (Date.now() - lastReadTime > timeout) { | ||
throw WebrpcStreamLostError.new({ | ||
cause: 'Stream timed out' | ||
let timeoutError = false; | ||
const intervalId = setInterval(() => { | ||
if (Date.now() - lastReadTime > timeout) { | ||
timeoutError = true; | ||
clearInterval(intervalId); | ||
reader.releaseLock(); | ||
} | ||
}, timeout); | ||
while (true) { | ||
let value; | ||
let done; | ||
try { | ||
; | ||
({ | ||
value, | ||
done | ||
} = await reader.read()); | ||
if (timeoutError) throw new Error('Timeout, no data or heartbeat received'); | ||
lastReadTime = Date.now(); | ||
buffer += decoder.decode(value, { | ||
stream: true | ||
}); | ||
} catch (error) { | ||
let message = ''; | ||
if (error instanceof Error) { | ||
message = error.message; | ||
} | ||
if (error instanceof DOMException && error.name === 'AbortError') { | ||
onError(WebrpcRequestFailedError.new({ | ||
message: 'AbortError', | ||
cause: `AbortError: ${message}` | ||
}), () => { | ||
throw new Error('Abort signal cannot be used to reconnect'); | ||
}); | ||
} else { | ||
onError(WebrpcStreamLostError.new({ | ||
cause: `reader.read(): ${message}` | ||
}), retryFetch); | ||
} | ||
}, timeout); | ||
while (true) { | ||
let value; | ||
let done; | ||
return; | ||
} | ||
let lines = buffer.split('\n'); | ||
for (let i = 0; i < lines.length - 1; i++) { | ||
if (lines[i].length == 0) { | ||
continue; | ||
} | ||
let data; | ||
try { | ||
; | ||
({ | ||
value, | ||
done | ||
} = await reader.read()); | ||
lastReadTime = Date.now(); | ||
buffer += decoder.decode(value, { | ||
stream: true | ||
}); | ||
data = JSON.parse(lines[i]); | ||
if (data.hasOwnProperty('webrpcError')) { | ||
const error = data.webrpcError; | ||
const code = typeof error.code === 'number' ? error.code : 0; | ||
onError((webrpcErrorByCode[code] || WebrpcError).new(error), retryFetch); | ||
return; | ||
} | ||
} catch (error) { | ||
let message = ''; | ||
if (error instanceof Error) { | ||
message = error.message; | ||
if (error instanceof Error && error.message === 'Abort signal cannot be used to reconnect') { | ||
throw error; | ||
} | ||
if (error instanceof DOMException && error.name === 'AbortError') { | ||
onError(WebrpcRequestFailedError.new({ | ||
message: 'AbortError', | ||
cause: `AbortError: ${message}` | ||
}), () => { | ||
throw new Error('Abort signal cannot be used to reconnect'); | ||
}); | ||
} else { | ||
onError(WebrpcStreamLostError.new({ | ||
cause: `reader.read(): ${message}` | ||
}), retryFetch); | ||
} | ||
return; | ||
onError(WebrpcBadResponseError.new({ | ||
status: res.status, | ||
// @ts-ignore | ||
cause: `JSON.parse(): ${error.message}` | ||
}), retryFetch); | ||
} | ||
let lines = buffer.split('\n'); | ||
for (let i = 0; i < lines.length - 1; i++) { | ||
if (lines[i].length == 0) { | ||
continue; | ||
} | ||
let data; | ||
try { | ||
data = JSON.parse(lines[i]); | ||
if (data.hasOwnProperty('webrpcError')) { | ||
const error = data.webrpcError; | ||
const code = typeof error.code === 'number' ? error.code : 0; | ||
onError((webrpcErrorByCode[code] || WebrpcError).new(error), retryFetch); | ||
return; | ||
} | ||
} catch (error) { | ||
if (error instanceof Error && error.message === 'Abort signal cannot be used to reconnect') { | ||
throw error; | ||
} | ||
onError(WebrpcBadResponseError.new({ | ||
status: res.status, | ||
// @ts-ignore | ||
cause: `JSON.parse(): ${error.message}` | ||
}), retryFetch); | ||
} | ||
onMessage(data); | ||
} | ||
if (!done) { | ||
buffer = lines[lines.length - 1]; | ||
continue; | ||
} | ||
onClose && onClose(); | ||
return; | ||
onMessage(data); | ||
} | ||
} catch (error) { | ||
// @ts-ignore | ||
if (error instanceof WebrpcStreamLostError) { | ||
onError(error, retryFetch); | ||
} else { | ||
throw error; | ||
if (!done) { | ||
buffer = lines[lines.length - 1]; | ||
continue; | ||
} | ||
} finally { | ||
clearInterval(intervalId); | ||
onClose && onClose(); | ||
return; | ||
} | ||
@@ -857,2 +903,3 @@ }; | ||
exports.ContractType = ContractType; | ||
exports.ContractVerificationStatus = ContractVerificationStatus; | ||
exports.EventLogDataType = EventLogDataType; | ||
@@ -859,0 +906,0 @@ exports.EventLogType = EventLogType; |
function _extends() { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
return _extends = Object.assign ? Object.assign.bind() : function (n) { | ||
for (var e = 1; e < arguments.length; e++) { | ||
var t = arguments[e]; | ||
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
return n; | ||
}, _extends.apply(null, arguments); | ||
} | ||
/* eslint-disable */ | ||
// sequence-indexer v0.4.0 9accea267e7db3d66f40d5e0f27db92eb5a29e2f | ||
// sequence-indexer v0.4.0 cae735346d8e5c3dce48dce9f85116989b6beffd | ||
// -- | ||
// Code generated by webrpc-gen@v0.18.6 with typescript generator. DO NOT EDIT. | ||
// Code generated by webrpc-gen@v0.20.3 with typescript generator. DO NOT EDIT. | ||
// | ||
@@ -30,3 +25,3 @@ // webrpc-gen -schema=indexer.ridl -target=typescript -client -out=./clients/indexer.gen.ts | ||
// Schema hash generated from your RIDL schema | ||
const WebRPCSchemaHash = '9accea267e7db3d66f40d5e0f27db92eb5a29e2f'; | ||
const WebRPCSchemaHash = 'cae735346d8e5c3dce48dce9f85116989b6beffd'; | ||
@@ -91,2 +86,8 @@ // | ||
}({}); | ||
let ContractVerificationStatus = /*#__PURE__*/function (ContractVerificationStatus) { | ||
ContractVerificationStatus["VERIFIED"] = "VERIFIED"; | ||
ContractVerificationStatus["UNVERIFIED"] = "UNVERIFIED"; | ||
ContractVerificationStatus["ALL"] = "ALL"; | ||
return ContractVerificationStatus; | ||
}({}); | ||
// | ||
@@ -165,2 +166,57 @@ // Client | ||
}; | ||
this.getNativeTokenBalance = (args, headers, signal) => { | ||
return this.fetch(this.url('GetNativeTokenBalance'), createHTTPRequest(args, headers, signal)).then(res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
balance: _data.balance | ||
}; | ||
}); | ||
}, 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.getTokenBalances = (args, headers, signal) => { | ||
@@ -429,3 +485,3 @@ return this.fetch(this.url('GetTokenBalances'), createHTTPRequest(args, headers, signal)).then(res => { | ||
}; | ||
this.hostname = hostname; | ||
this.hostname = hostname.replace(/\/*$/, ''); | ||
this.fetch = (input, init) => fetch(input, init); | ||
@@ -466,85 +522,75 @@ } | ||
const timeout = (10 + 1) * 1000; | ||
let intervalId; | ||
try { | ||
intervalId = setInterval(() => { | ||
if (Date.now() - lastReadTime > timeout) { | ||
throw WebrpcStreamLostError.new({ | ||
cause: 'Stream timed out' | ||
let timeoutError = false; | ||
const intervalId = setInterval(() => { | ||
if (Date.now() - lastReadTime > timeout) { | ||
timeoutError = true; | ||
clearInterval(intervalId); | ||
reader.releaseLock(); | ||
} | ||
}, timeout); | ||
while (true) { | ||
let value; | ||
let done; | ||
try { | ||
; | ||
({ | ||
value, | ||
done | ||
} = await reader.read()); | ||
if (timeoutError) throw new Error('Timeout, no data or heartbeat received'); | ||
lastReadTime = Date.now(); | ||
buffer += decoder.decode(value, { | ||
stream: true | ||
}); | ||
} catch (error) { | ||
let message = ''; | ||
if (error instanceof Error) { | ||
message = error.message; | ||
} | ||
if (error instanceof DOMException && error.name === 'AbortError') { | ||
onError(WebrpcRequestFailedError.new({ | ||
message: 'AbortError', | ||
cause: `AbortError: ${message}` | ||
}), () => { | ||
throw new Error('Abort signal cannot be used to reconnect'); | ||
}); | ||
} else { | ||
onError(WebrpcStreamLostError.new({ | ||
cause: `reader.read(): ${message}` | ||
}), retryFetch); | ||
} | ||
}, timeout); | ||
while (true) { | ||
let value; | ||
let done; | ||
return; | ||
} | ||
let lines = buffer.split('\n'); | ||
for (let i = 0; i < lines.length - 1; i++) { | ||
if (lines[i].length == 0) { | ||
continue; | ||
} | ||
let data; | ||
try { | ||
; | ||
({ | ||
value, | ||
done | ||
} = await reader.read()); | ||
lastReadTime = Date.now(); | ||
buffer += decoder.decode(value, { | ||
stream: true | ||
}); | ||
data = JSON.parse(lines[i]); | ||
if (data.hasOwnProperty('webrpcError')) { | ||
const error = data.webrpcError; | ||
const code = typeof error.code === 'number' ? error.code : 0; | ||
onError((webrpcErrorByCode[code] || WebrpcError).new(error), retryFetch); | ||
return; | ||
} | ||
} catch (error) { | ||
let message = ''; | ||
if (error instanceof Error) { | ||
message = error.message; | ||
if (error instanceof Error && error.message === 'Abort signal cannot be used to reconnect') { | ||
throw error; | ||
} | ||
if (error instanceof DOMException && error.name === 'AbortError') { | ||
onError(WebrpcRequestFailedError.new({ | ||
message: 'AbortError', | ||
cause: `AbortError: ${message}` | ||
}), () => { | ||
throw new Error('Abort signal cannot be used to reconnect'); | ||
}); | ||
} else { | ||
onError(WebrpcStreamLostError.new({ | ||
cause: `reader.read(): ${message}` | ||
}), retryFetch); | ||
} | ||
return; | ||
onError(WebrpcBadResponseError.new({ | ||
status: res.status, | ||
// @ts-ignore | ||
cause: `JSON.parse(): ${error.message}` | ||
}), retryFetch); | ||
} | ||
let lines = buffer.split('\n'); | ||
for (let i = 0; i < lines.length - 1; i++) { | ||
if (lines[i].length == 0) { | ||
continue; | ||
} | ||
let data; | ||
try { | ||
data = JSON.parse(lines[i]); | ||
if (data.hasOwnProperty('webrpcError')) { | ||
const error = data.webrpcError; | ||
const code = typeof error.code === 'number' ? error.code : 0; | ||
onError((webrpcErrorByCode[code] || WebrpcError).new(error), retryFetch); | ||
return; | ||
} | ||
} catch (error) { | ||
if (error instanceof Error && error.message === 'Abort signal cannot be used to reconnect') { | ||
throw error; | ||
} | ||
onError(WebrpcBadResponseError.new({ | ||
status: res.status, | ||
// @ts-ignore | ||
cause: `JSON.parse(): ${error.message}` | ||
}), retryFetch); | ||
} | ||
onMessage(data); | ||
} | ||
if (!done) { | ||
buffer = lines[lines.length - 1]; | ||
continue; | ||
} | ||
onClose && onClose(); | ||
return; | ||
onMessage(data); | ||
} | ||
} catch (error) { | ||
// @ts-ignore | ||
if (error instanceof WebrpcStreamLostError) { | ||
onError(error, retryFetch); | ||
} else { | ||
throw error; | ||
if (!done) { | ||
buffer = lines[lines.length - 1]; | ||
continue; | ||
} | ||
} finally { | ||
clearInterval(intervalId); | ||
onClose && onClose(); | ||
return; | ||
} | ||
@@ -850,2 +896,2 @@ }; | ||
export { AbortedError, ContractType, 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 }; | ||
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 }; |
export declare const WebRPCVersion = "v1"; | ||
export declare const WebRPCSchemaVersion = "v0.4.0"; | ||
export declare const WebRPCSchemaHash = "9accea267e7db3d66f40d5e0f27db92eb5a29e2f"; | ||
export declare const WebRPCSchemaHash = "cae735346d8e5c3dce48dce9f85116989b6beffd"; | ||
export interface ContractInfo { | ||
@@ -108,2 +108,7 @@ chainId: number; | ||
} | ||
export declare enum ContractVerificationStatus { | ||
VERIFIED = "VERIFIED", | ||
UNVERIFIED = "UNVERIFIED", | ||
ALL = "ALL" | ||
} | ||
export interface Version { | ||
@@ -179,2 +184,6 @@ webrpcVersion: string; | ||
} | ||
export interface NativeTokenBalance { | ||
accountAddress: string; | ||
balance: string; | ||
} | ||
export interface IndexState { | ||
@@ -230,2 +239,4 @@ chainId: string; | ||
chainId: number; | ||
uniqueCollectibles: string; | ||
isSummary: boolean; | ||
contractInfo?: ContractInfo; | ||
@@ -246,9 +257,15 @@ tokenMetadata?: TokenMetadata; | ||
createdBy: string; | ||
blockNumber: number; | ||
orderbookContractAddress: string; | ||
createdAt: number; | ||
orderbookContractAddress: string; | ||
} | ||
export interface OrderbookOrderFilter { | ||
isListing?: boolean; | ||
userAddresses?: Array<string>; | ||
tokenIds: Array<string>; | ||
excludeUserAddresses?: Array<string>; | ||
afterBlockNumber: number; | ||
afterCreatedAt: number; | ||
beforeExpiry: number; | ||
userAddress?: string; | ||
tokenIds: Array<string>; | ||
excludeUserAddress?: string; | ||
@@ -378,2 +395,13 @@ } | ||
} | ||
export interface TokenBalancesFilter { | ||
accountAddresses: Array<string>; | ||
contractStatus: ContractVerificationStatus; | ||
contractWhitelist: Array<string>; | ||
contractBlacklist: Array<string>; | ||
} | ||
export interface TokenBalancesByContractFilter { | ||
contractAddresses: Array<string>; | ||
accountAddresses: Array<string>; | ||
contractStatus: ContractVerificationStatus; | ||
} | ||
export interface Indexer { | ||
@@ -385,2 +413,6 @@ ping(headers?: object, signal?: AbortSignal): Promise<PingReturn>; | ||
getEtherBalance(args: GetEtherBalanceArgs, headers?: object, signal?: AbortSignal): Promise<GetEtherBalanceReturn>; | ||
getNativeTokenBalance(args: GetNativeTokenBalanceArgs, headers?: object, signal?: AbortSignal): Promise<GetNativeTokenBalanceReturn>; | ||
getTokenBalancesSummary(args: GetTokenBalancesSummaryArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenBalancesSummaryReturn>; | ||
getTokenBalancesDetails(args: GetTokenBalancesDetailsArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenBalancesDetailsReturn>; | ||
getTokenBalancesByContract(args: GetTokenBalancesByContractArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenBalancesByContractReturn>; | ||
getTokenBalances(args: GetTokenBalancesArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenBalancesReturn>; | ||
@@ -434,2 +466,35 @@ getTokenSupplies(args: GetTokenSuppliesArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenSuppliesReturn>; | ||
} | ||
export interface GetNativeTokenBalanceArgs { | ||
accountAddress?: string; | ||
} | ||
export interface GetNativeTokenBalanceReturn { | ||
balance: NativeTokenBalance; | ||
} | ||
export interface GetTokenBalancesSummaryArgs { | ||
filter: TokenBalancesFilter; | ||
omitMetadata?: boolean; | ||
page?: Page; | ||
} | ||
export interface GetTokenBalancesSummaryReturn { | ||
page: Page; | ||
balances: Array<TokenBalance>; | ||
} | ||
export interface GetTokenBalancesDetailsArgs { | ||
filter: TokenBalancesFilter; | ||
omitMetadata?: boolean; | ||
page?: Page; | ||
} | ||
export interface GetTokenBalancesDetailsReturn { | ||
page: Page; | ||
balances: Array<TokenBalance>; | ||
} | ||
export interface GetTokenBalancesByContractArgs { | ||
filter: TokenBalancesByContractFilter; | ||
omitMetadata?: boolean; | ||
page?: Page; | ||
} | ||
export interface GetTokenBalancesByContractReturn { | ||
page: Page; | ||
balances: Array<TokenBalance>; | ||
} | ||
export interface GetTokenBalancesArgs { | ||
@@ -510,5 +575,8 @@ accountAddress?: string; | ||
currencyAddresses: Array<string>; | ||
filter: OrderbookOrderFilter; | ||
orderStatuses: Array<OrderStatus>; | ||
filters: Array<OrderbookOrderFilter>; | ||
orderStatuses: Array<OrderStatus>; | ||
beforeExpiryTimestamp: number; | ||
blockNumberAfter: number; | ||
createdAtAfter: number; | ||
} | ||
@@ -617,25 +685,29 @@ export interface GetOrderbookOrdersReturn { | ||
private url; | ||
ping: (headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<PingReturn>; | ||
version: (headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<VersionReturn>; | ||
runtimeStatus: (headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<RuntimeStatusReturn>; | ||
getChainID: (headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<GetChainIDReturn>; | ||
getEtherBalance: (args: GetEtherBalanceArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<GetEtherBalanceReturn>; | ||
getTokenBalances: (args: GetTokenBalancesArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<GetTokenBalancesReturn>; | ||
getTokenSupplies: (args: GetTokenSuppliesArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<GetTokenSuppliesReturn>; | ||
getTokenSuppliesMap: (args: GetTokenSuppliesMapArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<GetTokenSuppliesMapReturn>; | ||
getBalanceUpdates: (args: GetBalanceUpdatesArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<GetBalanceUpdatesReturn>; | ||
getTransactionHistory: (args: GetTransactionHistoryArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<GetTransactionHistoryReturn>; | ||
syncBalance: (args: SyncBalanceArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<SyncBalanceReturn>; | ||
fetchTransactionReceipt: (args: FetchTransactionReceiptArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<FetchTransactionReceiptReturn>; | ||
getOrderbookOrders: (args: GetOrderbookOrdersArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<GetOrderbookOrdersReturn>; | ||
getTopOrders: (args: GetTopOrdersArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<GetTopOrdersReturn>; | ||
fetchTransactionReceiptWithFilter: (args: FetchTransactionReceiptWithFilterArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<FetchTransactionReceiptWithFilterReturn>; | ||
getAllWebhookListeners: (args: GetAllWebhookListenersArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<GetAllWebhookListenersReturn>; | ||
getWebhookListener: (args: GetWebhookListenerArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<GetWebhookListenerReturn>; | ||
addWebhookListener: (args: AddWebhookListenerArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<AddWebhookListenerReturn>; | ||
updateWebhookListener: (args: UpdateWebhookListenerArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<UpdateWebhookListenerReturn>; | ||
removeWebhookListener: (args: RemoveWebhookListenerArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<RemoveWebhookListenerReturn>; | ||
toggleWebhookListener: (args: ToggleWebhookListenerArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<ToggleWebhookListenerReturn>; | ||
pauseAllWebhookListeners: (args: PauseAllWebhookListenersArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<PauseAllWebhookListenersReturn>; | ||
resumeAllWebhookListeners: (args: ResumeAllWebhookListenersArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<ResumeAllWebhookListenersReturn>; | ||
ping: (headers?: object, signal?: AbortSignal) => Promise<PingReturn>; | ||
version: (headers?: object, signal?: AbortSignal) => Promise<VersionReturn>; | ||
runtimeStatus: (headers?: object, signal?: AbortSignal) => Promise<RuntimeStatusReturn>; | ||
getChainID: (headers?: object, signal?: AbortSignal) => Promise<GetChainIDReturn>; | ||
getEtherBalance: (args: GetEtherBalanceArgs, headers?: object, signal?: AbortSignal) => Promise<GetEtherBalanceReturn>; | ||
getNativeTokenBalance: (args: GetNativeTokenBalanceArgs, headers?: object, signal?: AbortSignal) => Promise<GetNativeTokenBalanceReturn>; | ||
getTokenBalancesSummary: (args: GetTokenBalancesSummaryArgs, headers?: object, signal?: AbortSignal) => Promise<GetTokenBalancesSummaryReturn>; | ||
getTokenBalancesDetails: (args: GetTokenBalancesDetailsArgs, headers?: object, signal?: AbortSignal) => Promise<GetTokenBalancesDetailsReturn>; | ||
getTokenBalancesByContract: (args: GetTokenBalancesByContractArgs, headers?: object, signal?: AbortSignal) => Promise<GetTokenBalancesByContractReturn>; | ||
getTokenBalances: (args: GetTokenBalancesArgs, headers?: object, signal?: AbortSignal) => Promise<GetTokenBalancesReturn>; | ||
getTokenSupplies: (args: GetTokenSuppliesArgs, headers?: object, signal?: AbortSignal) => Promise<GetTokenSuppliesReturn>; | ||
getTokenSuppliesMap: (args: GetTokenSuppliesMapArgs, headers?: object, signal?: AbortSignal) => Promise<GetTokenSuppliesMapReturn>; | ||
getBalanceUpdates: (args: GetBalanceUpdatesArgs, headers?: object, signal?: AbortSignal) => Promise<GetBalanceUpdatesReturn>; | ||
getTransactionHistory: (args: GetTransactionHistoryArgs, headers?: object, signal?: AbortSignal) => Promise<GetTransactionHistoryReturn>; | ||
syncBalance: (args: SyncBalanceArgs, headers?: object, signal?: AbortSignal) => Promise<SyncBalanceReturn>; | ||
fetchTransactionReceipt: (args: FetchTransactionReceiptArgs, headers?: object, signal?: AbortSignal) => Promise<FetchTransactionReceiptReturn>; | ||
getOrderbookOrders: (args: GetOrderbookOrdersArgs, headers?: object, signal?: AbortSignal) => Promise<GetOrderbookOrdersReturn>; | ||
getTopOrders: (args: GetTopOrdersArgs, headers?: object, signal?: AbortSignal) => Promise<GetTopOrdersReturn>; | ||
fetchTransactionReceiptWithFilter: (args: FetchTransactionReceiptWithFilterArgs, headers?: object, signal?: AbortSignal) => Promise<FetchTransactionReceiptWithFilterReturn>; | ||
getAllWebhookListeners: (args: GetAllWebhookListenersArgs, headers?: object, signal?: AbortSignal) => Promise<GetAllWebhookListenersReturn>; | ||
getWebhookListener: (args: GetWebhookListenerArgs, headers?: object, signal?: AbortSignal) => Promise<GetWebhookListenerReturn>; | ||
addWebhookListener: (args: AddWebhookListenerArgs, headers?: object, signal?: AbortSignal) => Promise<AddWebhookListenerReturn>; | ||
updateWebhookListener: (args: UpdateWebhookListenerArgs, headers?: object, signal?: AbortSignal) => Promise<UpdateWebhookListenerReturn>; | ||
removeWebhookListener: (args: RemoveWebhookListenerArgs, headers?: object, signal?: AbortSignal) => Promise<RemoveWebhookListenerReturn>; | ||
toggleWebhookListener: (args: ToggleWebhookListenerArgs, headers?: object, signal?: AbortSignal) => Promise<ToggleWebhookListenerReturn>; | ||
pauseAllWebhookListeners: (args: PauseAllWebhookListenersArgs, headers?: object, signal?: AbortSignal) => Promise<PauseAllWebhookListenersReturn>; | ||
resumeAllWebhookListeners: (args: ResumeAllWebhookListenersArgs, headers?: object, signal?: AbortSignal) => Promise<ResumeAllWebhookListenersReturn>; | ||
subscribeReceipts: (args: SubscribeReceiptsArgs, options: WebrpcStreamOptions<SubscribeReceiptsReturn>) => Promise<void>; | ||
@@ -642,0 +714,0 @@ subscribeEvents: (args: SubscribeEventsArgs, options: WebrpcStreamOptions<SubscribeEventsReturn>) => Promise<void>; |
{ | ||
"name": "@0xsequence/indexer", | ||
"version": "0.0.0-20241007154931", | ||
"version": "0.0.0-20241107182529", | ||
"description": "indexer sub-package for Sequence", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/indexer", |
/* eslint-disable */ | ||
// sequence-indexer v0.4.0 9accea267e7db3d66f40d5e0f27db92eb5a29e2f | ||
// sequence-indexer v0.4.0 cae735346d8e5c3dce48dce9f85116989b6beffd | ||
// -- | ||
// Code generated by webrpc-gen@v0.18.6 with typescript generator. DO NOT EDIT. | ||
// Code generated by webrpc-gen@v0.20.3 with typescript generator. DO NOT EDIT. | ||
// | ||
@@ -15,3 +15,3 @@ // webrpc-gen -schema=indexer.ridl -target=typescript -client -out=./clients/indexer.gen.ts | ||
// Schema hash generated from your RIDL schema | ||
export const WebRPCSchemaHash = '9accea267e7db3d66f40d5e0f27db92eb5a29e2f' | ||
export const WebRPCSchemaHash = 'cae735346d8e5c3dce48dce9f85116989b6beffd' | ||
@@ -134,2 +134,8 @@ // | ||
export enum ContractVerificationStatus { | ||
VERIFIED = 'VERIFIED', | ||
UNVERIFIED = 'UNVERIFIED', | ||
ALL = 'ALL' | ||
} | ||
export interface Version { | ||
@@ -212,2 +218,7 @@ webrpcVersion: string | ||
export interface NativeTokenBalance { | ||
accountAddress: string | ||
balance: string | ||
} | ||
export interface IndexState { | ||
@@ -266,2 +277,4 @@ chainId: string | ||
chainId: number | ||
uniqueCollectibles: string | ||
isSummary: boolean | ||
contractInfo?: ContractInfo | ||
@@ -283,4 +296,5 @@ tokenMetadata?: TokenMetadata | ||
createdBy: string | ||
blockNumber: number | ||
orderbookContractAddress: string | ||
createdAt: number | ||
orderbookContractAddress: string | ||
} | ||
@@ -290,4 +304,9 @@ | ||
isListing?: boolean | ||
userAddresses?: Array<string> | ||
tokenIds: Array<string> | ||
excludeUserAddresses?: Array<string> | ||
afterBlockNumber: number | ||
afterCreatedAt: number | ||
beforeExpiry: number | ||
userAddress?: string | ||
tokenIds: Array<string> | ||
excludeUserAddress?: string | ||
@@ -430,2 +449,15 @@ } | ||
export interface TokenBalancesFilter { | ||
accountAddresses: Array<string> | ||
contractStatus: ContractVerificationStatus | ||
contractWhitelist: Array<string> | ||
contractBlacklist: Array<string> | ||
} | ||
export interface TokenBalancesByContractFilter { | ||
contractAddresses: Array<string> | ||
accountAddresses: Array<string> | ||
contractStatus: ContractVerificationStatus | ||
} | ||
export interface Indexer { | ||
@@ -437,2 +469,22 @@ ping(headers?: object, signal?: AbortSignal): Promise<PingReturn> | ||
getEtherBalance(args: GetEtherBalanceArgs, headers?: object, signal?: AbortSignal): Promise<GetEtherBalanceReturn> | ||
getNativeTokenBalance( | ||
args: GetNativeTokenBalanceArgs, | ||
headers?: object, | ||
signal?: AbortSignal | ||
): Promise<GetNativeTokenBalanceReturn> | ||
getTokenBalancesSummary( | ||
args: GetTokenBalancesSummaryArgs, | ||
headers?: object, | ||
signal?: AbortSignal | ||
): Promise<GetTokenBalancesSummaryReturn> | ||
getTokenBalancesDetails( | ||
args: GetTokenBalancesDetailsArgs, | ||
headers?: object, | ||
signal?: AbortSignal | ||
): Promise<GetTokenBalancesDetailsReturn> | ||
getTokenBalancesByContract( | ||
args: GetTokenBalancesByContractArgs, | ||
headers?: object, | ||
signal?: AbortSignal | ||
): Promise<GetTokenBalancesByContractReturn> | ||
getTokenBalances(args: GetTokenBalancesArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenBalancesReturn> | ||
@@ -527,2 +579,39 @@ getTokenSupplies(args: GetTokenSuppliesArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenSuppliesReturn> | ||
} | ||
export interface GetNativeTokenBalanceArgs { | ||
accountAddress?: string | ||
} | ||
export interface GetNativeTokenBalanceReturn { | ||
balance: NativeTokenBalance | ||
} | ||
export interface GetTokenBalancesSummaryArgs { | ||
filter: TokenBalancesFilter | ||
omitMetadata?: boolean | ||
page?: Page | ||
} | ||
export interface GetTokenBalancesSummaryReturn { | ||
page: Page | ||
balances: Array<TokenBalance> | ||
} | ||
export interface GetTokenBalancesDetailsArgs { | ||
filter: TokenBalancesFilter | ||
omitMetadata?: boolean | ||
page?: Page | ||
} | ||
export interface GetTokenBalancesDetailsReturn { | ||
page: Page | ||
balances: Array<TokenBalance> | ||
} | ||
export interface GetTokenBalancesByContractArgs { | ||
filter: TokenBalancesByContractFilter | ||
omitMetadata?: boolean | ||
page?: Page | ||
} | ||
export interface GetTokenBalancesByContractReturn { | ||
page: Page | ||
balances: Array<TokenBalance> | ||
} | ||
export interface GetTokenBalancesArgs { | ||
@@ -605,5 +694,8 @@ accountAddress?: string | ||
currencyAddresses: Array<string> | ||
filter: OrderbookOrderFilter | ||
orderStatuses: Array<OrderStatus> | ||
filters: Array<OrderbookOrderFilter> | ||
orderStatuses: Array<OrderStatus> | ||
beforeExpiryTimestamp: number | ||
blockNumberAfter: number | ||
createdAtAfter: number | ||
} | ||
@@ -730,3 +822,3 @@ | ||
constructor(hostname: string, fetch: Fetch) { | ||
this.hostname = hostname | ||
this.hostname = hostname.replace(/\/*$/, '') | ||
this.fetch = (input: RequestInfo, init?: RequestInit) => fetch(input, init) | ||
@@ -814,2 +906,81 @@ } | ||
getNativeTokenBalance = ( | ||
args: GetNativeTokenBalanceArgs, | ||
headers?: object, | ||
signal?: AbortSignal | ||
): Promise<GetNativeTokenBalanceReturn> => { | ||
return this.fetch(this.url('GetNativeTokenBalance'), createHTTPRequest(args, headers, signal)).then( | ||
res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
balance: <NativeTokenBalance>_data.balance | ||
} | ||
}) | ||
}, | ||
error => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
} | ||
) | ||
} | ||
getTokenBalancesSummary = ( | ||
args: GetTokenBalancesSummaryArgs, | ||
headers?: object, | ||
signal?: AbortSignal | ||
): Promise<GetTokenBalancesSummaryReturn> => { | ||
return this.fetch(this.url('GetTokenBalancesSummary'), createHTTPRequest(args, headers, signal)).then( | ||
res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: <Page>_data.page, | ||
balances: <Array<TokenBalance>>_data.balances | ||
} | ||
}) | ||
}, | ||
error => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
} | ||
) | ||
} | ||
getTokenBalancesDetails = ( | ||
args: GetTokenBalancesDetailsArgs, | ||
headers?: object, | ||
signal?: AbortSignal | ||
): Promise<GetTokenBalancesDetailsReturn> => { | ||
return this.fetch(this.url('GetTokenBalancesDetails'), createHTTPRequest(args, headers, signal)).then( | ||
res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: <Page>_data.page, | ||
balances: <Array<TokenBalance>>_data.balances | ||
} | ||
}) | ||
}, | ||
error => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
} | ||
) | ||
} | ||
getTokenBalancesByContract = ( | ||
args: GetTokenBalancesByContractArgs, | ||
headers?: object, | ||
signal?: AbortSignal | ||
): Promise<GetTokenBalancesByContractReturn> => { | ||
return this.fetch(this.url('GetTokenBalancesByContract'), createHTTPRequest(args, headers, signal)).then( | ||
res => { | ||
return buildResponse(res).then(_data => { | ||
return { | ||
page: <Page>_data.page, | ||
balances: <Array<TokenBalance>>_data.balances | ||
} | ||
}) | ||
}, | ||
error => { | ||
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) | ||
} | ||
) | ||
} | ||
getTokenBalances = (args: GetTokenBalancesArgs, headers?: object, signal?: AbortSignal): Promise<GetTokenBalancesReturn> => { | ||
@@ -1214,92 +1385,83 @@ return this.fetch(this.url('GetTokenBalances'), createHTTPRequest(args, headers, signal)).then( | ||
const timeout = (10 + 1) * 1000 | ||
let intervalId: any | ||
let timeoutError = false | ||
const intervalId = setInterval(() => { | ||
if (Date.now() - lastReadTime > timeout) { | ||
timeoutError = true | ||
clearInterval(intervalId) | ||
reader.releaseLock() | ||
} | ||
}, timeout) | ||
try { | ||
intervalId = setInterval(() => { | ||
if (Date.now() - lastReadTime > timeout) { | ||
throw WebrpcStreamLostError.new({ cause: 'Stream timed out' }) | ||
while (true) { | ||
let value | ||
let done | ||
try { | ||
;({ value, done } = await reader.read()) | ||
if (timeoutError) throw new Error('Timeout, no data or heartbeat received') | ||
lastReadTime = Date.now() | ||
buffer += decoder.decode(value, { stream: true }) | ||
} catch (error) { | ||
let message = '' | ||
if (error instanceof Error) { | ||
message = error.message | ||
} | ||
}, timeout) | ||
while (true) { | ||
let value | ||
let done | ||
try { | ||
;({ value, done } = await reader.read()) | ||
lastReadTime = Date.now() | ||
buffer += decoder.decode(value, { stream: true }) | ||
} catch (error) { | ||
let message = '' | ||
if (error instanceof Error) { | ||
message = error.message | ||
} | ||
if (error instanceof DOMException && error.name === 'AbortError') { | ||
onError( | ||
WebrpcRequestFailedError.new({ | ||
message: 'AbortError', | ||
cause: `AbortError: ${message}` | ||
}), | ||
() => { | ||
throw new Error('Abort signal cannot be used to reconnect') | ||
} | ||
) | ||
} else { | ||
onError( | ||
WebrpcStreamLostError.new({ | ||
cause: `reader.read(): ${message}` | ||
}), | ||
retryFetch | ||
) | ||
} | ||
return | ||
} | ||
if (error instanceof DOMException && error.name === 'AbortError') { | ||
onError( | ||
WebrpcRequestFailedError.new({ | ||
message: 'AbortError', | ||
cause: `AbortError: ${message}` | ||
}), | ||
() => { | ||
throw new Error('Abort signal cannot be used to reconnect') | ||
} | ||
) | ||
} else { | ||
onError( | ||
WebrpcStreamLostError.new({ | ||
cause: `reader.read(): ${message}` | ||
}), | ||
retryFetch | ||
) | ||
} | ||
return | ||
let lines = buffer.split('\n') | ||
for (let i = 0; i < lines.length - 1; i++) { | ||
if (lines[i].length == 0) { | ||
continue | ||
} | ||
let lines = buffer.split('\n') | ||
for (let i = 0; i < lines.length - 1; i++) { | ||
if (lines[i].length == 0) { | ||
continue | ||
let data: any | ||
try { | ||
data = JSON.parse(lines[i]) | ||
if (data.hasOwnProperty('webrpcError')) { | ||
const error = data.webrpcError | ||
const code: number = typeof error.code === 'number' ? error.code : 0 | ||
onError((webrpcErrorByCode[code] || WebrpcError).new(error), retryFetch) | ||
return | ||
} | ||
let data: any | ||
try { | ||
data = JSON.parse(lines[i]) | ||
if (data.hasOwnProperty('webrpcError')) { | ||
const error = data.webrpcError | ||
const code: number = typeof error.code === 'number' ? error.code : 0 | ||
onError((webrpcErrorByCode[code] || WebrpcError).new(error), retryFetch) | ||
return | ||
} | ||
} catch (error) { | ||
if (error instanceof Error && error.message === 'Abort signal cannot be used to reconnect') { | ||
throw error | ||
} | ||
onError( | ||
WebrpcBadResponseError.new({ | ||
status: res.status, | ||
// @ts-ignore | ||
cause: `JSON.parse(): ${error.message}` | ||
}), | ||
retryFetch | ||
) | ||
} catch (error) { | ||
if (error instanceof Error && error.message === 'Abort signal cannot be used to reconnect') { | ||
throw error | ||
} | ||
onMessage(data) | ||
onError( | ||
WebrpcBadResponseError.new({ | ||
status: res.status, | ||
// @ts-ignore | ||
cause: `JSON.parse(): ${error.message}` | ||
}), | ||
retryFetch | ||
) | ||
} | ||
onMessage(data) | ||
} | ||
if (!done) { | ||
buffer = lines[lines.length - 1] | ||
continue | ||
} | ||
if (!done) { | ||
buffer = lines[lines.length - 1] | ||
continue | ||
} | ||
onClose && onClose() | ||
return | ||
} | ||
} catch (error) { | ||
// @ts-ignore | ||
if (error instanceof WebrpcStreamLostError) { | ||
onError(error, retryFetch) | ||
} else { | ||
throw error | ||
} | ||
} finally { | ||
clearInterval(intervalId) | ||
onClose && onClose() | ||
return | ||
} | ||
@@ -1306,0 +1468,0 @@ } |
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
193246
5343