@injectivelabs/sdk-ts 0.0.29 → 0.0.30

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.
@@ -0,0 +1,7 @@
1
+ export declare class ApolloConsumer {
2
+ private apolloClient;
3
+ constructor(graphQlEndpoint: string);
4
+ fetchUserDeposits(address: string): Promise<import("./types").UserDeposit[]>;
5
+ fetchUserBridgeDeposits(address: string, timestamp: number): Promise<import("./types").UserDeposit[]>;
6
+ }
7
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/client/gql/client.ts"],"names":[],"mappings":"AASA,qBAAa,cAAc;IACzB,OAAO,CAAC,YAAY,CAAqC;gBAE7C,eAAe,EAAE,MAAM;IAa7B,iBAAiB,CAAC,OAAO,EAAE,MAAM;IAiBjC,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAejE"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ApolloConsumer = void 0;
13
+ const core_1 = require("@apollo/client/core");
14
+ const queries_1 = require("./queries");
15
+ class ApolloConsumer {
16
+ constructor(graphQlEndpoint) {
17
+ this.apolloClient = new core_1.ApolloClient({
18
+ uri: graphQlEndpoint,
19
+ cache: new core_1.InMemoryCache(),
20
+ defaultOptions: {
21
+ query: {
22
+ fetchPolicy: 'no-cache',
23
+ errorPolicy: 'all',
24
+ },
25
+ },
26
+ });
27
+ }
28
+ fetchUserDeposits(address) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ const response = (yield this.apolloClient.query({
31
+ query: queries_1.USER_DEPOSITS,
32
+ variables: {
33
+ destination: `0x${'0'.repeat(24)}${address
34
+ .toLowerCase()
35
+ .replace('0x', '')}`,
36
+ },
37
+ }));
38
+ if (response.errors && response.errors.length > 0) {
39
+ throw new Error(response.errors[0].message);
40
+ }
41
+ return response.data.deposits;
42
+ });
43
+ }
44
+ fetchUserBridgeDeposits(address, timestamp) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const response = (yield this.apolloClient.query({
47
+ query: queries_1.USER_BRIDGE_DEPOSITS,
48
+ variables: {
49
+ timestamp,
50
+ sender: address,
51
+ },
52
+ }));
53
+ if (response.errors && response.errors.length > 0) {
54
+ throw new Error(response.errors[0].message);
55
+ }
56
+ return response.data.deposits;
57
+ });
58
+ }
59
+ }
60
+ exports.ApolloConsumer = ApolloConsumer;
61
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/client/gql/client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAK4B;AAC5B,uCAA+D;AAG/D,MAAa,cAAc;IAGzB,YAAY,eAAuB;QACjC,IAAI,CAAC,YAAY,GAAG,IAAI,mBAAY,CAAC;YACnC,GAAG,EAAE,eAAe;YACpB,KAAK,EAAE,IAAI,oBAAa,EAAE;YAC1B,cAAc,EAAE;gBACd,KAAK,EAAE;oBACL,WAAW,EAAE,UAAU;oBACvB,WAAW,EAAE,KAAK;iBACnB;aACF;SACF,CAAC,CAAA;IACJ,CAAC;IAEK,iBAAiB,CAAC,OAAe;;YACrC,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;gBAC9C,KAAK,EAAE,uBAAa;gBACpB,SAAS,EAAE;oBACT,WAAW,EAAE,KAAK,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,OAAO;yBACvC,WAAW,EAAE;yBACb,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE;iBACvB;aACF,CAAC,CAA2C,CAAA;YAE7C,IAAI,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;gBACjD,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;aAC5C;YAED,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAA;QAC/B,CAAC;KAAA;IAEK,uBAAuB,CAAC,OAAe,EAAE,SAAiB;;YAC9D,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;gBAC9C,KAAK,EAAE,8BAAoB;gBAC3B,SAAS,EAAE;oBACT,SAAS;oBACT,MAAM,EAAE,OAAO;iBAChB;aACF,CAAC,CAA2C,CAAA;YAE7C,IAAI,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;gBACjD,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;aAC5C;YAED,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAA;QAC/B,CAAC;KAAA;CACF;AAhDD,wCAgDC"}
@@ -0,0 +1,4 @@
1
+ export * from './client';
2
+ export * from './queries';
3
+ export * from './types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/gql/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./client"), exports);
14
+ __exportStar(require("./queries"), exports);
15
+ __exportStar(require("./types"), exports);
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/gql/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAwB;AACxB,4CAAyB;AACzB,0CAAuB"}
@@ -0,0 +1,3 @@
1
+ export declare const USER_DEPOSITS: import("graphql/language/ast").DocumentNode;
2
+ export declare const USER_BRIDGE_DEPOSITS: import("graphql/language/ast").DocumentNode;
3
+ //# sourceMappingURL=queries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/client/gql/queries.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,6CAkBzB,CAAA;AAED,eAAO,MAAM,oBAAoB,6CAiBhC,CAAA"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.USER_BRIDGE_DEPOSITS = exports.USER_DEPOSITS = void 0;
4
+ const core_1 = require("@apollo/client/core");
5
+ exports.USER_DEPOSITS = (0, core_1.gql) `
6
+ query Deposits($destination: Bytes!) {
7
+ deposits(
8
+ orderBy: timestamp
9
+ orderDirection: desc
10
+ first: 10
11
+ where: { destination: $destination }
12
+ ) {
13
+ id
14
+ tokenContract
15
+ sender
16
+ destination
17
+ eventNonce
18
+ amount
19
+ timestamp
20
+ blockHeight
21
+ }
22
+ }
23
+ `;
24
+ exports.USER_BRIDGE_DEPOSITS = (0, core_1.gql) `
25
+ query Deposits($sender: Bytes!, $timestamp: Int!) {
26
+ deposits(
27
+ orderBy: timestamp
28
+ orderDirection: desc
29
+ where: { timestamp_gte: $timestamp, sender: $sender }
30
+ ) {
31
+ id
32
+ tokenContract
33
+ sender
34
+ destination
35
+ eventNonce
36
+ amount
37
+ timestamp
38
+ blockHeight
39
+ }
40
+ }
41
+ `;
42
+ //# sourceMappingURL=queries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/client/gql/queries.ts"],"names":[],"mappings":";;;AAAA,8CAAyC;AAE5B,QAAA,aAAa,GAAG,IAAA,UAAG,EAAA;;;;;;;;;;;;;;;;;;CAkB/B,CAAA;AAEY,QAAA,oBAAoB,GAAG,IAAA,UAAG,EAAA;;;;;;;;;;;;;;;;;CAiBtC,CAAA"}
@@ -0,0 +1,14 @@
1
+ export interface UserDeposit {
2
+ id: string;
3
+ tokenContract: string;
4
+ sender: string;
5
+ destination: string;
6
+ amount: string;
7
+ eventNonce: number;
8
+ timestamp: number;
9
+ blockHeight: number;
10
+ }
11
+ export interface UserDepositResponse {
12
+ deposits: UserDeposit[];
13
+ }
14
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/client/gql/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,WAAW,EAAE,CAAA;CACxB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/gql/types.ts"],"names":[],"mappings":""}
@@ -1,3 +1,4 @@
1
1
  export * as ChainClient from './chain';
2
2
  export * as ExchangeClient from './exchange';
3
+ export * as GqlClient from './gql';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,cAAc,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,cAAc,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,SAAS,MAAM,OAAO,CAAA"}
@@ -19,7 +19,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
19
19
  return result;
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.ExchangeClient = exports.ChainClient = void 0;
22
+ exports.GqlClient = exports.ExchangeClient = exports.ChainClient = void 0;
23
23
  exports.ChainClient = __importStar(require("./chain"));
24
24
  exports.ExchangeClient = __importStar(require("./exchange"));
25
+ exports.GqlClient = __importStar(require("./gql"));
25
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAsC;AACtC,6DAA4C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAsC;AACtC,6DAA4C;AAC5C,mDAAkC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@injectivelabs/sdk-ts",
3
3
  "description": "SDK in TypeScript for building Injective applications in a Node environment.",
4
- "version": "0.0.29",
4
+ "version": "0.0.30",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Bojan Angjelkoski",
@@ -55,5 +55,5 @@
55
55
  "snakecase-keys": "^5.4.1",
56
56
  "tiny-secp256k1": "^2.2.1"
57
57
  },
58
- "gitHead": "11650d3cd6a05198e355a44f02ba01d54da67799"
58
+ "gitHead": "f031d1d516ac29c58881824472ef46d27e152f5b"
59
59
  }