@shapeshiftoss/unchained-client 10.0.2 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cosmossdk/cosmos/index.d.ts +2 -0
- package/dist/{cosmos → cosmossdk/cosmos}/index.js +1 -2
- package/dist/cosmossdk/cosmos/parser/index.d.ts +6 -0
- package/dist/cosmossdk/cosmos/parser/index.js +12 -0
- package/dist/cosmossdk/index.d.ts +5 -0
- package/dist/cosmossdk/index.js +34 -0
- package/dist/cosmossdk/osmosis/index.d.ts +2 -0
- package/dist/{osmosis → cosmossdk/osmosis}/index.js +2 -1
- package/dist/cosmossdk/osmosis/parser/index.d.ts +6 -0
- package/dist/cosmossdk/osmosis/parser/index.js +12 -0
- package/dist/cosmossdk/parser/index.d.ts +12 -0
- package/dist/cosmossdk/parser/index.js +85 -0
- package/dist/{cosmos → cosmossdk/parser}/types.d.ts +3 -1
- package/dist/{cosmos → cosmossdk/parser}/types.js +0 -0
- package/dist/cosmossdk/parser/utils.d.ts +3 -0
- package/dist/cosmossdk/parser/utils.js +63 -0
- package/dist/cosmossdk/thorchain/index.d.ts +2 -0
- package/dist/cosmossdk/thorchain/index.js +18 -0
- package/dist/cosmossdk/thorchain/parser/index.d.ts +6 -0
- package/dist/cosmossdk/thorchain/parser/index.js +12 -0
- package/dist/cosmossdk/types.d.ts +1 -0
- package/dist/cosmossdk/types.js +2 -0
- package/dist/generated/cosmos/api.d.ts +18 -10
- package/dist/generated/osmosis/api.d.ts +18 -10
- package/dist/generated/thorchain/api.d.ts +1300 -0
- package/dist/generated/thorchain/api.js +520 -0
- package/dist/generated/thorchain/base.d.ts +55 -0
- package/dist/generated/thorchain/base.js +64 -0
- package/dist/generated/thorchain/common.d.ts +65 -0
- package/dist/generated/thorchain/common.js +137 -0
- package/dist/generated/thorchain/configuration.d.ts +83 -0
- package/dist/generated/thorchain/configuration.js +42 -0
- package/dist/generated/thorchain/index.d.ts +13 -0
- package/dist/generated/thorchain/index.js +31 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +5 -3
- package/package.json +1 -1
- package/dist/cosmos/index.d.ts +0 -3
- package/dist/cosmos/parser/index.d.ts +0 -13
- package/dist/cosmos/parser/index.js +0 -71
- package/dist/cosmos/parser/utils.d.ts +0 -13
- package/dist/cosmos/parser/utils.js +0 -145
- package/dist/osmosis/index.d.ts +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thorchain Unchained API
|
|
3
|
+
* Provides access to thorchain chain data.
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 1.0.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
import { Configuration } from "./configuration";
|
|
13
|
+
import { RequestArgs } from "./base";
|
|
14
|
+
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @export
|
|
18
|
+
*/
|
|
19
|
+
export declare const DUMMY_BASE_URL = "https://example.com";
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @throws {RequiredError}
|
|
23
|
+
* @export
|
|
24
|
+
*/
|
|
25
|
+
export declare const assertParamExists: (functionName: string, paramName: string, paramValue: unknown) => void;
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @export
|
|
29
|
+
*/
|
|
30
|
+
export declare const setApiKeyToObject: (object: any, keyParamName: string, configuration?: Configuration | undefined) => Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @export
|
|
34
|
+
*/
|
|
35
|
+
export declare const setBasicAuthToObject: (object: any, configuration?: Configuration | undefined) => void;
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @export
|
|
39
|
+
*/
|
|
40
|
+
export declare const setBearerAuthToObject: (object: any, configuration?: Configuration | undefined) => Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @export
|
|
44
|
+
*/
|
|
45
|
+
export declare const setOAuthToObject: (object: any, name: string, scopes: string[], configuration?: Configuration | undefined) => Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @export
|
|
49
|
+
*/
|
|
50
|
+
export declare const setSearchParams: (url: URL, ...objects: any[]) => void;
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @export
|
|
54
|
+
*/
|
|
55
|
+
export declare const serializeDataIfNeeded: (value: any, requestOptions: any, configuration?: Configuration | undefined) => any;
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @export
|
|
59
|
+
*/
|
|
60
|
+
export declare const toPathString: (url: URL) => string;
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @export
|
|
64
|
+
*/
|
|
65
|
+
export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration | undefined) => <T = unknown, R = AxiosResponse<T, any>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* Thorchain Unchained API
|
|
6
|
+
* Provides access to thorchain chain data.
|
|
7
|
+
*
|
|
8
|
+
* The version of the OpenAPI document: 1.0.0
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
+
* https://openapi-generator.tech
|
|
13
|
+
* Do not edit the class manually.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.createRequestFunction = exports.toPathString = exports.serializeDataIfNeeded = exports.setSearchParams = exports.setOAuthToObject = exports.setBearerAuthToObject = exports.setBasicAuthToObject = exports.setApiKeyToObject = exports.assertParamExists = exports.DUMMY_BASE_URL = void 0;
|
|
17
|
+
const base_1 = require("./base");
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @export
|
|
21
|
+
*/
|
|
22
|
+
exports.DUMMY_BASE_URL = 'https://example.com';
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @throws {RequiredError}
|
|
26
|
+
* @export
|
|
27
|
+
*/
|
|
28
|
+
const assertParamExists = function (functionName, paramName, paramValue) {
|
|
29
|
+
if (paramValue === null || paramValue === undefined) {
|
|
30
|
+
throw new base_1.RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
exports.assertParamExists = assertParamExists;
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @export
|
|
37
|
+
*/
|
|
38
|
+
const setApiKeyToObject = async function (object, keyParamName, configuration) {
|
|
39
|
+
if (configuration && configuration.apiKey) {
|
|
40
|
+
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
|
41
|
+
? await configuration.apiKey(keyParamName)
|
|
42
|
+
: await configuration.apiKey;
|
|
43
|
+
object[keyParamName] = localVarApiKeyValue;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.setApiKeyToObject = setApiKeyToObject;
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @export
|
|
50
|
+
*/
|
|
51
|
+
const setBasicAuthToObject = function (object, configuration) {
|
|
52
|
+
if (configuration && (configuration.username || configuration.password)) {
|
|
53
|
+
object["auth"] = { username: configuration.username, password: configuration.password };
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
exports.setBasicAuthToObject = setBasicAuthToObject;
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @export
|
|
60
|
+
*/
|
|
61
|
+
const setBearerAuthToObject = async function (object, configuration) {
|
|
62
|
+
if (configuration && configuration.accessToken) {
|
|
63
|
+
const accessToken = typeof configuration.accessToken === 'function'
|
|
64
|
+
? await configuration.accessToken()
|
|
65
|
+
: await configuration.accessToken;
|
|
66
|
+
object["Authorization"] = "Bearer " + accessToken;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
exports.setBearerAuthToObject = setBearerAuthToObject;
|
|
70
|
+
/**
|
|
71
|
+
*
|
|
72
|
+
* @export
|
|
73
|
+
*/
|
|
74
|
+
const setOAuthToObject = async function (object, name, scopes, configuration) {
|
|
75
|
+
if (configuration && configuration.accessToken) {
|
|
76
|
+
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
|
|
77
|
+
? await configuration.accessToken(name, scopes)
|
|
78
|
+
: await configuration.accessToken;
|
|
79
|
+
object["Authorization"] = "Bearer " + localVarAccessTokenValue;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
exports.setOAuthToObject = setOAuthToObject;
|
|
83
|
+
/**
|
|
84
|
+
*
|
|
85
|
+
* @export
|
|
86
|
+
*/
|
|
87
|
+
const setSearchParams = function (url, ...objects) {
|
|
88
|
+
const searchParams = new URLSearchParams(url.search);
|
|
89
|
+
for (const object of objects) {
|
|
90
|
+
for (const key in object) {
|
|
91
|
+
if (Array.isArray(object[key])) {
|
|
92
|
+
searchParams.delete(key);
|
|
93
|
+
for (const item of object[key]) {
|
|
94
|
+
searchParams.append(key, item);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
searchParams.set(key, object[key]);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
url.search = searchParams.toString();
|
|
103
|
+
};
|
|
104
|
+
exports.setSearchParams = setSearchParams;
|
|
105
|
+
/**
|
|
106
|
+
*
|
|
107
|
+
* @export
|
|
108
|
+
*/
|
|
109
|
+
const serializeDataIfNeeded = function (value, requestOptions, configuration) {
|
|
110
|
+
const nonString = typeof value !== 'string';
|
|
111
|
+
const needsSerialization = nonString && configuration && configuration.isJsonMime
|
|
112
|
+
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
|
|
113
|
+
: nonString;
|
|
114
|
+
return needsSerialization
|
|
115
|
+
? JSON.stringify(value !== undefined ? value : {})
|
|
116
|
+
: (value || "");
|
|
117
|
+
};
|
|
118
|
+
exports.serializeDataIfNeeded = serializeDataIfNeeded;
|
|
119
|
+
/**
|
|
120
|
+
*
|
|
121
|
+
* @export
|
|
122
|
+
*/
|
|
123
|
+
const toPathString = function (url) {
|
|
124
|
+
return url.pathname + url.search + url.hash;
|
|
125
|
+
};
|
|
126
|
+
exports.toPathString = toPathString;
|
|
127
|
+
/**
|
|
128
|
+
*
|
|
129
|
+
* @export
|
|
130
|
+
*/
|
|
131
|
+
const createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) {
|
|
132
|
+
return (axios = globalAxios, basePath = BASE_PATH) => {
|
|
133
|
+
const axiosRequestArgs = { ...axiosArgs.options, url: ((configuration === null || configuration === void 0 ? void 0 : configuration.basePath) || basePath) + axiosArgs.url };
|
|
134
|
+
return axios.request(axiosRequestArgs);
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
exports.createRequestFunction = createRequestFunction;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thorchain Unchained API
|
|
3
|
+
* Provides access to thorchain chain data.
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 1.0.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
export interface ConfigurationParameters {
|
|
13
|
+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
|
14
|
+
username?: string;
|
|
15
|
+
password?: string;
|
|
16
|
+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
|
17
|
+
basePath?: string;
|
|
18
|
+
baseOptions?: any;
|
|
19
|
+
formDataCtor?: new () => any;
|
|
20
|
+
}
|
|
21
|
+
export declare class Configuration {
|
|
22
|
+
/**
|
|
23
|
+
* parameter for apiKey security
|
|
24
|
+
* @param name security name
|
|
25
|
+
* @memberof Configuration
|
|
26
|
+
*/
|
|
27
|
+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
|
28
|
+
/**
|
|
29
|
+
* parameter for basic security
|
|
30
|
+
*
|
|
31
|
+
* @type {string}
|
|
32
|
+
* @memberof Configuration
|
|
33
|
+
*/
|
|
34
|
+
username?: string;
|
|
35
|
+
/**
|
|
36
|
+
* parameter for basic security
|
|
37
|
+
*
|
|
38
|
+
* @type {string}
|
|
39
|
+
* @memberof Configuration
|
|
40
|
+
*/
|
|
41
|
+
password?: string;
|
|
42
|
+
/**
|
|
43
|
+
* parameter for oauth2 security
|
|
44
|
+
* @param name security name
|
|
45
|
+
* @param scopes oauth2 scope
|
|
46
|
+
* @memberof Configuration
|
|
47
|
+
*/
|
|
48
|
+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
|
49
|
+
/**
|
|
50
|
+
* override base path
|
|
51
|
+
*
|
|
52
|
+
* @type {string}
|
|
53
|
+
* @memberof Configuration
|
|
54
|
+
*/
|
|
55
|
+
basePath?: string;
|
|
56
|
+
/**
|
|
57
|
+
* base options for axios calls
|
|
58
|
+
*
|
|
59
|
+
* @type {any}
|
|
60
|
+
* @memberof Configuration
|
|
61
|
+
*/
|
|
62
|
+
baseOptions?: any;
|
|
63
|
+
/**
|
|
64
|
+
* The FormData constructor that will be used to create multipart form data
|
|
65
|
+
* requests. You can inject this here so that execution environments that
|
|
66
|
+
* do not support the FormData class can still run the generated client.
|
|
67
|
+
*
|
|
68
|
+
* @type {new () => FormData}
|
|
69
|
+
*/
|
|
70
|
+
formDataCtor?: new () => any;
|
|
71
|
+
constructor(param?: ConfigurationParameters);
|
|
72
|
+
/**
|
|
73
|
+
* Check if the given MIME is a JSON MIME.
|
|
74
|
+
* JSON MIME examples:
|
|
75
|
+
* application/json
|
|
76
|
+
* application/json; charset=UTF8
|
|
77
|
+
* APPLICATION/JSON
|
|
78
|
+
* application/vnd.company+json
|
|
79
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
80
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
81
|
+
*/
|
|
82
|
+
isJsonMime(mime: string): boolean;
|
|
83
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* Thorchain Unchained API
|
|
6
|
+
* Provides access to thorchain chain data.
|
|
7
|
+
*
|
|
8
|
+
* The version of the OpenAPI document: 1.0.0
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
+
* https://openapi-generator.tech
|
|
13
|
+
* Do not edit the class manually.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.Configuration = void 0;
|
|
17
|
+
class Configuration {
|
|
18
|
+
constructor(param = {}) {
|
|
19
|
+
this.apiKey = param.apiKey;
|
|
20
|
+
this.username = param.username;
|
|
21
|
+
this.password = param.password;
|
|
22
|
+
this.accessToken = param.accessToken;
|
|
23
|
+
this.basePath = param.basePath;
|
|
24
|
+
this.baseOptions = param.baseOptions;
|
|
25
|
+
this.formDataCtor = param.formDataCtor;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Check if the given MIME is a JSON MIME.
|
|
29
|
+
* JSON MIME examples:
|
|
30
|
+
* application/json
|
|
31
|
+
* application/json; charset=UTF8
|
|
32
|
+
* APPLICATION/JSON
|
|
33
|
+
* application/vnd.company+json
|
|
34
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
35
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
36
|
+
*/
|
|
37
|
+
isJsonMime(mime) {
|
|
38
|
+
const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
|
39
|
+
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.Configuration = Configuration;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thorchain Unchained API
|
|
3
|
+
* Provides access to thorchain chain data.
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 1.0.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
export * from "./api";
|
|
13
|
+
export * from "./configuration";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* Thorchain Unchained API
|
|
6
|
+
* Provides access to thorchain chain data.
|
|
7
|
+
*
|
|
8
|
+
* The version of the OpenAPI document: 1.0.0
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
+
* https://openapi-generator.tech
|
|
13
|
+
* Do not edit the class manually.
|
|
14
|
+
*/
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
27
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
__exportStar(require("./api"), exports);
|
|
31
|
+
__exportStar(require("./configuration"), exports);
|
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,13 @@ export * from './types';
|
|
|
2
2
|
export * as ws from './websocket';
|
|
3
3
|
export * as evm from './evm';
|
|
4
4
|
export * as utxo from './utxo';
|
|
5
|
+
export * as cosmossdk from './cosmossdk';
|
|
5
6
|
export * as ethereum from './evm/ethereum';
|
|
6
7
|
export * as avalanche from './evm/avalanche';
|
|
7
8
|
export * as bitcoin from './utxo/bitcoin';
|
|
8
9
|
export * as bitcoincash from './utxo/bitcoincash';
|
|
9
10
|
export * as dogecoin from './utxo/dogecoin';
|
|
10
11
|
export * as litecoin from './utxo/litecoin';
|
|
11
|
-
export * as cosmos from './cosmos';
|
|
12
|
-
export * as osmosis from './osmosis';
|
|
12
|
+
export * as cosmos from './cosmossdk/cosmos';
|
|
13
|
+
export * as osmosis from './cosmossdk/osmosis';
|
|
14
|
+
export * as thorchain from './cosmossdk/thorchain';
|
package/dist/index.js
CHANGED
|
@@ -26,16 +26,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.osmosis = exports.cosmos = exports.litecoin = exports.dogecoin = exports.bitcoincash = exports.bitcoin = exports.avalanche = exports.ethereum = exports.utxo = exports.evm = exports.ws = void 0;
|
|
29
|
+
exports.thorchain = exports.osmosis = exports.cosmos = exports.litecoin = exports.dogecoin = exports.bitcoincash = exports.bitcoin = exports.avalanche = exports.ethereum = exports.cosmossdk = exports.utxo = exports.evm = exports.ws = void 0;
|
|
30
30
|
__exportStar(require("./types"), exports);
|
|
31
31
|
exports.ws = __importStar(require("./websocket"));
|
|
32
32
|
exports.evm = __importStar(require("./evm"));
|
|
33
33
|
exports.utxo = __importStar(require("./utxo"));
|
|
34
|
+
exports.cosmossdk = __importStar(require("./cosmossdk"));
|
|
34
35
|
exports.ethereum = __importStar(require("./evm/ethereum"));
|
|
35
36
|
exports.avalanche = __importStar(require("./evm/avalanche"));
|
|
36
37
|
exports.bitcoin = __importStar(require("./utxo/bitcoin"));
|
|
37
38
|
exports.bitcoincash = __importStar(require("./utxo/bitcoincash"));
|
|
38
39
|
exports.dogecoin = __importStar(require("./utxo/dogecoin"));
|
|
39
40
|
exports.litecoin = __importStar(require("./utxo/litecoin"));
|
|
40
|
-
exports.cosmos = __importStar(require("./cosmos"));
|
|
41
|
-
exports.osmosis = __importStar(require("./osmosis"));
|
|
41
|
+
exports.cosmos = __importStar(require("./cosmossdk/cosmos"));
|
|
42
|
+
exports.osmosis = __importStar(require("./cosmossdk/osmosis"));
|
|
43
|
+
exports.thorchain = __importStar(require("./cosmossdk/thorchain"));
|
package/package.json
CHANGED
package/dist/cosmos/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
2
|
-
import { Tx as CosmosTx } from '../index';
|
|
3
|
-
import { ParsedTx } from '../types';
|
|
4
|
-
export interface TransactionParserArgs {
|
|
5
|
-
chainId: ChainId;
|
|
6
|
-
assetId?: AssetId;
|
|
7
|
-
}
|
|
8
|
-
export declare class TransactionParser {
|
|
9
|
-
chainId: ChainId;
|
|
10
|
-
assetId: AssetId;
|
|
11
|
-
constructor(args: TransactionParserArgs);
|
|
12
|
-
parse(tx: CosmosTx, address: string): Promise<ParsedTx>;
|
|
13
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TransactionParser = void 0;
|
|
4
|
-
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
|
-
const bignumber_js_1 = require("bignumber.js");
|
|
6
|
-
const types_1 = require("../../types");
|
|
7
|
-
const utils_1 = require("./utils");
|
|
8
|
-
class TransactionParser {
|
|
9
|
-
constructor(args) {
|
|
10
|
-
var _a;
|
|
11
|
-
this.chainId = args.chainId;
|
|
12
|
-
this.assetId =
|
|
13
|
-
(_a = args === null || args === void 0 ? void 0 : args.assetId) !== null && _a !== void 0 ? _a : (0, caip_1.toAssetId)({
|
|
14
|
-
...(0, caip_1.fromChainId)(this.chainId),
|
|
15
|
-
assetNamespace: 'slip44',
|
|
16
|
-
assetReference: caip_1.ASSET_REFERENCE.Cosmos,
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
async parse(tx, address) {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
const parsedTx = {
|
|
22
|
-
address,
|
|
23
|
-
blockHash: tx.blockHash,
|
|
24
|
-
blockHeight: (_a = tx.blockHeight) !== null && _a !== void 0 ? _a : -1,
|
|
25
|
-
blockTime: (_b = tx.timestamp) !== null && _b !== void 0 ? _b : Math.floor(Date.now() / 1000),
|
|
26
|
-
chainId: this.chainId,
|
|
27
|
-
confirmations: tx.confirmations,
|
|
28
|
-
status: tx.confirmations > 0 ? types_1.TxStatus.Confirmed : types_1.TxStatus.Pending,
|
|
29
|
-
transfers: [],
|
|
30
|
-
txid: tx.txid,
|
|
31
|
-
};
|
|
32
|
-
// For simplicity and to limit scope we assume 1 message per transaction
|
|
33
|
-
// This works ok enough for transactions we generate but way may want to improve in the future
|
|
34
|
-
const { from, to, data, value, origin } = (0, utils_1.valuesFromMsgEvents)(tx.messages[0], tx.events, this.assetId, address);
|
|
35
|
-
parsedTx.data = data;
|
|
36
|
-
if (from === address && value.gt(0)) {
|
|
37
|
-
parsedTx.transfers = [
|
|
38
|
-
{
|
|
39
|
-
type: types_1.TransferType.Send,
|
|
40
|
-
assetId: this.assetId,
|
|
41
|
-
from,
|
|
42
|
-
to,
|
|
43
|
-
totalValue: value.toString(10),
|
|
44
|
-
components: [{ value: value.toString(10) }],
|
|
45
|
-
},
|
|
46
|
-
];
|
|
47
|
-
}
|
|
48
|
-
if (to === address && value.gt(0)) {
|
|
49
|
-
parsedTx.transfers = [
|
|
50
|
-
{
|
|
51
|
-
type: types_1.TransferType.Receive,
|
|
52
|
-
assetId: this.assetId,
|
|
53
|
-
from,
|
|
54
|
-
to,
|
|
55
|
-
totalValue: value.toString(10),
|
|
56
|
-
components: [{ value: value.toString(10) }],
|
|
57
|
-
},
|
|
58
|
-
];
|
|
59
|
-
}
|
|
60
|
-
// We use origin for fees because some txs have a different from and origin addresses
|
|
61
|
-
if (origin === address) {
|
|
62
|
-
// network fee
|
|
63
|
-
const fees = new bignumber_js_1.BigNumber(tx.fee.amount);
|
|
64
|
-
if (fees.gt(0)) {
|
|
65
|
-
parsedTx.fee = { assetId: this.assetId, value: fees.toString(10) };
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return parsedTx;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
exports.TransactionParser = TransactionParser;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { AssetId } from '@shapeshiftoss/caip';
|
|
2
|
-
import BigNumber from 'bignumber.js';
|
|
3
|
-
import { Event, Message } from '../../generated/cosmos';
|
|
4
|
-
import { TxMetadata } from '../types';
|
|
5
|
-
export declare const valuesFromMsgEvents: (msg: Message, events: {
|
|
6
|
-
[key: string]: Event[];
|
|
7
|
-
}, assetId: AssetId, address: string) => {
|
|
8
|
-
from: string;
|
|
9
|
-
to: string;
|
|
10
|
-
value: BigNumber;
|
|
11
|
-
data: TxMetadata | undefined;
|
|
12
|
-
origin: string;
|
|
13
|
-
};
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.valuesFromMsgEvents = void 0;
|
|
7
|
-
const logger_1 = require("@shapeshiftoss/logger");
|
|
8
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
9
|
-
const logger = new logger_1.Logger({
|
|
10
|
-
namespace: ['client', 'cosmos', 'utils'],
|
|
11
|
-
level: process.env.LOG_LEVEL,
|
|
12
|
-
});
|
|
13
|
-
const metaData = (msg, assetId) => {
|
|
14
|
-
var _a, _b, _c, _d;
|
|
15
|
-
if (!msg)
|
|
16
|
-
return;
|
|
17
|
-
switch (msg.type) {
|
|
18
|
-
case 'delegate':
|
|
19
|
-
case 'begin_unbonding':
|
|
20
|
-
return {
|
|
21
|
-
parser: 'cosmos',
|
|
22
|
-
method: msg.type,
|
|
23
|
-
delegator: msg.from,
|
|
24
|
-
destinationValidator: msg.to,
|
|
25
|
-
value: (_a = msg === null || msg === void 0 ? void 0 : msg.value) === null || _a === void 0 ? void 0 : _a.amount,
|
|
26
|
-
};
|
|
27
|
-
case 'begin_redelegate':
|
|
28
|
-
return {
|
|
29
|
-
parser: 'cosmos',
|
|
30
|
-
method: msg.type,
|
|
31
|
-
sourceValidator: msg.from,
|
|
32
|
-
delegator: msg.origin,
|
|
33
|
-
destinationValidator: msg.to,
|
|
34
|
-
value: (_b = msg === null || msg === void 0 ? void 0 : msg.value) === null || _b === void 0 ? void 0 : _b.amount,
|
|
35
|
-
assetId,
|
|
36
|
-
};
|
|
37
|
-
case 'withdraw_delegator_reward':
|
|
38
|
-
return {
|
|
39
|
-
parser: 'cosmos',
|
|
40
|
-
method: msg.type,
|
|
41
|
-
destinationValidator: msg.to,
|
|
42
|
-
value: (_c = msg === null || msg === void 0 ? void 0 : msg.value) === null || _c === void 0 ? void 0 : _c.amount,
|
|
43
|
-
assetId,
|
|
44
|
-
};
|
|
45
|
-
case 'ibc_send':
|
|
46
|
-
case 'ibc_receive':
|
|
47
|
-
return {
|
|
48
|
-
parser: 'cosmos',
|
|
49
|
-
method: msg.type,
|
|
50
|
-
ibcDestination: msg.to,
|
|
51
|
-
ibcSource: msg.from,
|
|
52
|
-
assetId,
|
|
53
|
-
value: (_d = msg === null || msg === void 0 ? void 0 : msg.value) === null || _d === void 0 ? void 0 : _d.amount,
|
|
54
|
-
};
|
|
55
|
-
// known message types with no applicable metadata
|
|
56
|
-
case 'send':
|
|
57
|
-
return;
|
|
58
|
-
default:
|
|
59
|
-
logger.warn(`unsupported message type: ${msg.type}`);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const virtualMessageFromEvents = (msg, events, address) => {
|
|
64
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
65
|
-
// ibc send tx indicated by events
|
|
66
|
-
const ibcSendEventData = (_a = events[0]) === null || _a === void 0 ? void 0 : _a.find((event) => event.type === 'send_packet');
|
|
67
|
-
// ibc receive tx indicated by events
|
|
68
|
-
const ibcReceivedData = Object.values(events).find((event) => event.some((subEvent) => subEvent.type === 'coin_received' &&
|
|
69
|
-
subEvent.attributes[0].key === 'receiver' &&
|
|
70
|
-
subEvent.attributes[0].value.toLowerCase() === address.toLowerCase()));
|
|
71
|
-
const ibcRecvEventData = ibcReceivedData === null || ibcReceivedData === void 0 ? void 0 : ibcReceivedData.find((event) => {
|
|
72
|
-
return event.type === 'recv_packet';
|
|
73
|
-
});
|
|
74
|
-
// get rewards tx indicted by events
|
|
75
|
-
const rewardEventData = (_b = events[0]) === null || _b === void 0 ? void 0 : _b.find((event) => event.type === 'withdraw_rewards');
|
|
76
|
-
// Osmo swap tx. This works for now as a general cosmos-sdk parser
|
|
77
|
-
// Eventually may want an osmo parser on its own
|
|
78
|
-
const swapEventData = (_c = events[0]) === null || _c === void 0 ? void 0 : _c.find((event) => event.type === 'token_swapped');
|
|
79
|
-
if (ibcSendEventData) {
|
|
80
|
-
const parsedPacketData = JSON.parse((_e = (_d = ibcSendEventData === null || ibcSendEventData === void 0 ? void 0 : ibcSendEventData.attributes.find((attribute) => attribute.key === 'packet_data')) === null || _d === void 0 ? void 0 : _d.value) !== null && _e !== void 0 ? _e : '{}');
|
|
81
|
-
// We dont support parsing ibc sends unless they are atom or osmo
|
|
82
|
-
if (parsedPacketData.denom === 'uatom' || parsedPacketData.denom === 'uosmo')
|
|
83
|
-
return {
|
|
84
|
-
type: 'ibc_send',
|
|
85
|
-
value: { amount: parsedPacketData.amount, denom: parsedPacketData.denom },
|
|
86
|
-
from: parsedPacketData.sender,
|
|
87
|
-
to: parsedPacketData.receiver,
|
|
88
|
-
origin: parsedPacketData.sender,
|
|
89
|
-
};
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
else if (ibcRecvEventData) {
|
|
93
|
-
const parsedPacketData = JSON.parse((_g = (_f = ibcRecvEventData === null || ibcRecvEventData === void 0 ? void 0 : ibcRecvEventData.attributes.find((attribute) => attribute.key === 'packet_data')) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : '{}');
|
|
94
|
-
// Osmosis IBC receives are showing up as osmosis. (Requires further debugging, probably during a swapper re-write)
|
|
95
|
-
// This hack ignores ibc deposits into osmosis
|
|
96
|
-
// Its fine because ibc assets only ephemerally exist on osmosis during a swap
|
|
97
|
-
if (parsedPacketData.receiver.startsWith('osmo'))
|
|
98
|
-
return;
|
|
99
|
-
return {
|
|
100
|
-
type: 'ibc_receive',
|
|
101
|
-
value: { amount: parsedPacketData.amount, denom: parsedPacketData.denom },
|
|
102
|
-
from: parsedPacketData.sender,
|
|
103
|
-
to: parsedPacketData.receiver,
|
|
104
|
-
origin: parsedPacketData.sender,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
else if (rewardEventData) {
|
|
108
|
-
const valueUnparsed = (_j = (_h = rewardEventData === null || rewardEventData === void 0 ? void 0 : rewardEventData.attributes) === null || _h === void 0 ? void 0 : _h.find((attribute) => attribute.key === 'amount')) === null || _j === void 0 ? void 0 : _j.value;
|
|
109
|
-
const valueParsed = valueUnparsed === null || valueUnparsed === void 0 ? void 0 : valueUnparsed.slice(0, valueUnparsed.length - 'uatom'.length);
|
|
110
|
-
return {
|
|
111
|
-
type: 'withdraw_delegator_reward',
|
|
112
|
-
value: { amount: valueParsed !== null && valueParsed !== void 0 ? valueParsed : '', denom: 'uatom' },
|
|
113
|
-
from: msg.from,
|
|
114
|
-
to: msg.to,
|
|
115
|
-
origin: msg.origin,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
else if (swapEventData) {
|
|
119
|
-
const sender = (_k = swapEventData.attributes.find((attribute) => attribute.key === 'sender')) === null || _k === void 0 ? void 0 : _k.value;
|
|
120
|
-
const swapAmount = (_l = swapEventData.attributes.find((attribute) => attribute.key === 'tokens_out')) === null || _l === void 0 ? void 0 : _l.value;
|
|
121
|
-
const valueParsed = (_m = swapAmount === null || swapAmount === void 0 ? void 0 : swapAmount.slice(0, (swapAmount === null || swapAmount === void 0 ? void 0 : swapAmount.length) - 'uosmo'.length)) !== null && _m !== void 0 ? _m : '';
|
|
122
|
-
if (swapAmount === null || swapAmount === void 0 ? void 0 : swapAmount.includes('uosmo'))
|
|
123
|
-
return {
|
|
124
|
-
type: 'send',
|
|
125
|
-
value: { amount: valueParsed, denom: 'uosmo' },
|
|
126
|
-
to: sender,
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
// no virtual message handled, but also no transaction message
|
|
130
|
-
if (!msg) {
|
|
131
|
-
logger.warn(`no transaction message found and unable to create virtual message from events: ${events}`);
|
|
132
|
-
}
|
|
133
|
-
return msg;
|
|
134
|
-
};
|
|
135
|
-
const valuesFromMsgEvents = (msg, events, assetId, address) => {
|
|
136
|
-
var _a, _b, _c, _d;
|
|
137
|
-
const virtualMsg = virtualMessageFromEvents(msg, events, address);
|
|
138
|
-
const data = metaData(virtualMsg, assetId);
|
|
139
|
-
const from = (_a = virtualMsg === null || virtualMsg === void 0 ? void 0 : virtualMsg.from) !== null && _a !== void 0 ? _a : '';
|
|
140
|
-
const to = (_b = virtualMsg === null || virtualMsg === void 0 ? void 0 : virtualMsg.to) !== null && _b !== void 0 ? _b : '';
|
|
141
|
-
const origin = (_c = virtualMsg === null || virtualMsg === void 0 ? void 0 : virtualMsg.origin) !== null && _c !== void 0 ? _c : '';
|
|
142
|
-
const value = new bignumber_js_1.default(((_d = virtualMsg === null || virtualMsg === void 0 ? void 0 : virtualMsg.value) === null || _d === void 0 ? void 0 : _d.amount) || (data === null || data === void 0 ? void 0 : data.value) || 0);
|
|
143
|
-
return { from, to, value, data, origin };
|
|
144
|
-
};
|
|
145
|
-
exports.valuesFromMsgEvents = valuesFromMsgEvents;
|