@ledgerhq/context-module 0.0.1 → 0.0.2-nightly.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/package.json +1 -1
- package/lib/ContextModule.d.ts +0 -7
- package/lib/ContextModule.d.ts.map +0 -1
- package/lib/ContextModule.js +0 -3
- package/lib/ContextModule.js.map +0 -1
- package/lib/DefaultContextModule.d.ts +0 -15
- package/lib/DefaultContextModule.d.ts.map +0 -1
- package/lib/DefaultContextModule.js +0 -26
- package/lib/DefaultContextModule.js.map +0 -1
- package/lib/DefaultContextModule.test.d.ts +0 -2
- package/lib/DefaultContextModule.test.d.ts.map +0 -1
- package/lib/DefaultContextModule.test.js +0 -45
- package/lib/DefaultContextModule.test.js.map +0 -1
- package/lib/forward-domain/data/ForwardDomainDataSource.d.ts +0 -8
- package/lib/forward-domain/data/ForwardDomainDataSource.d.ts.map +0 -1
- package/lib/forward-domain/data/ForwardDomainDataSource.js +0 -3
- package/lib/forward-domain/data/ForwardDomainDataSource.js.map +0 -1
- package/lib/forward-domain/data/HttpForwardDomainDataSource.d.ts +0 -5
- package/lib/forward-domain/data/HttpForwardDomainDataSource.d.ts.map +0 -1
- package/lib/forward-domain/data/HttpForwardDomainDataSource.js +0 -29
- package/lib/forward-domain/data/HttpForwardDomainDataSource.js.map +0 -1
- package/lib/forward-domain/domain/ForwardDomainContextLoader.d.ts +0 -12
- package/lib/forward-domain/domain/ForwardDomainContextLoader.d.ts.map +0 -1
- package/lib/forward-domain/domain/ForwardDomainContextLoader.js +0 -50
- package/lib/forward-domain/domain/ForwardDomainContextLoader.js.map +0 -1
- package/lib/forward-domain/domain/ForwardDomainContextLoader.test.d.ts +0 -2
- package/lib/forward-domain/domain/ForwardDomainContextLoader.test.d.ts.map +0 -1
- package/lib/forward-domain/domain/ForwardDomainContextLoader.test.js +0 -85
- package/lib/forward-domain/domain/ForwardDomainContextLoader.test.js.map +0 -1
- package/lib/index.d.ts +0 -2
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -18
- package/lib/index.js.map +0 -1
- package/lib/nft/data/HttpNftDataSource.d.ts +0 -6
- package/lib/nft/data/HttpNftDataSource.d.ts.map +0 -1
- package/lib/nft/data/HttpNftDataSource.js +0 -38
- package/lib/nft/data/HttpNftDataSource.js.map +0 -1
- package/lib/nft/data/NftDataSource.d.ts +0 -14
- package/lib/nft/data/NftDataSource.d.ts.map +0 -1
- package/lib/nft/data/NftDataSource.js +0 -3
- package/lib/nft/data/NftDataSource.js.map +0 -1
- package/lib/nft/domain/NftContextLoader.d.ts +0 -12
- package/lib/nft/domain/NftContextLoader.d.ts.map +0 -1
- package/lib/nft/domain/NftContextLoader.js +0 -79
- package/lib/nft/domain/NftContextLoader.js.map +0 -1
- package/lib/nft/domain/NftContextLoader.test.d.ts +0 -2
- package/lib/nft/domain/NftContextLoader.test.d.ts.map +0 -1
- package/lib/nft/domain/NftContextLoader.test.js +0 -113
- package/lib/nft/domain/NftContextLoader.test.js.map +0 -1
- package/lib/shared/domain/ContextLoader.d.ts +0 -7
- package/lib/shared/domain/ContextLoader.d.ts.map +0 -1
- package/lib/shared/domain/ContextLoader.js +0 -3
- package/lib/shared/domain/ContextLoader.js.map +0 -1
- package/lib/shared/model/ContextResponse.d.ts +0 -11
- package/lib/shared/model/ContextResponse.d.ts.map +0 -1
- package/lib/shared/model/ContextResponse.js +0 -3
- package/lib/shared/model/ContextResponse.js.map +0 -1
- package/lib/shared/model/LoaderOptions.d.ts +0 -10
- package/lib/shared/model/LoaderOptions.d.ts.map +0 -1
- package/lib/shared/model/LoaderOptions.js +0 -3
- package/lib/shared/model/LoaderOptions.js.map +0 -1
- package/lib/shared/model/Transaction.d.ts +0 -2
- package/lib/shared/model/Transaction.d.ts.map +0 -1
- package/lib/shared/model/Transaction.js +0 -3
- package/lib/shared/model/Transaction.js.map +0 -1
package/package.json
CHANGED
package/lib/ContextModule.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ContextResponse } from "./shared/model/ContextResponse";
|
|
2
|
-
import { LoaderOptions } from "./shared/model/LoaderOptions";
|
|
3
|
-
import { Transaction } from "./shared/model/Transaction";
|
|
4
|
-
export interface ContextModule {
|
|
5
|
-
getContexts(transaction: Transaction, options: LoaderOptions): Promise<ContextResponse[]>;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=ContextModule.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContextModule.d.ts","sourceRoot":"","sources":["../src/ContextModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;CAC3F"}
|
package/lib/ContextModule.js
DELETED
package/lib/ContextModule.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContextModule.js","sourceRoot":"","sources":["../src/ContextModule.ts"],"names":[],"mappings":""}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ContextModule } from "./ContextModule";
|
|
2
|
-
import { ContextLoader } from "./shared/domain/ContextLoader";
|
|
3
|
-
import { ContextResponse } from "./shared/model/ContextResponse";
|
|
4
|
-
import { LoaderOptions } from "./shared/model/LoaderOptions";
|
|
5
|
-
import { Transaction } from "./shared/model/Transaction";
|
|
6
|
-
type DefaultContextModuleConstructorArgs = {
|
|
7
|
-
loaders: ContextLoader[];
|
|
8
|
-
};
|
|
9
|
-
export declare class DefaultContextModule implements ContextModule {
|
|
10
|
-
private _loaders;
|
|
11
|
-
constructor({ loaders: loaders }: DefaultContextModuleConstructorArgs);
|
|
12
|
-
getContexts(transaction: Transaction, options: LoaderOptions): Promise<ContextResponse[]>;
|
|
13
|
-
}
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=DefaultContextModule.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultContextModule.d.ts","sourceRoot":"","sources":["../src/DefaultContextModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,KAAK,mCAAmC,GAAG;IACzC,OAAO,EAAE,aAAa,EAAE,CAAC;CAC1B,CAAC;AAEF,qBAAa,oBAAqB,YAAW,aAAa;IACxD,OAAO,CAAC,QAAQ,CAAkB;gBAEtB,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,mCAAmC;IAIxD,WAAW,CACtB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,eAAe,EAAE,CAAC;CAK9B"}
|
|
@@ -1,26 +0,0 @@
|
|
|
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.DefaultContextModule = void 0;
|
|
13
|
-
class DefaultContextModule {
|
|
14
|
-
constructor({ loaders: loaders }) {
|
|
15
|
-
this._loaders = loaders;
|
|
16
|
-
}
|
|
17
|
-
getContexts(transaction, options) {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const promises = this._loaders.map(fetcher => fetcher.load(transaction, options));
|
|
20
|
-
const responses = yield Promise.all(promises);
|
|
21
|
-
return responses.flat();
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.DefaultContextModule = DefaultContextModule;
|
|
26
|
-
//# sourceMappingURL=DefaultContextModule.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultContextModule.js","sourceRoot":"","sources":["../src/DefaultContextModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AAUA,MAAa,oBAAoB;IAG/B,YAAY,EAAE,OAAO,EAAE,OAAO,EAAuC;QACnE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAEY,WAAW,CACtB,WAAwB,EACxB,OAAsB;;YAEtB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;YAClF,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC9C,OAAO,SAAS,CAAC,IAAI,EAAE,CAAC;QAC1B,CAAC;KAAA;CACF;AAfD,oDAeC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultContextModule.test.d.ts","sourceRoot":"","sources":["../src/DefaultContextModule.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,45 +0,0 @@
|
|
|
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
|
-
const DefaultContextModule_1 = require("./DefaultContextModule");
|
|
13
|
-
const contextLoaderStubBuilder = () => {
|
|
14
|
-
return { load: jest.fn() };
|
|
15
|
-
};
|
|
16
|
-
describe("DefaultContextModule", () => {
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
jest.restoreAllMocks();
|
|
19
|
-
});
|
|
20
|
-
it("should call all fetch method from metadata fetcher", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
-
const loader = contextLoaderStubBuilder();
|
|
22
|
-
const contextModule = new DefaultContextModule_1.DefaultContextModule({ loaders: [loader, loader] });
|
|
23
|
-
yield contextModule.getContexts({}, {});
|
|
24
|
-
expect(loader.load).toHaveBeenCalledTimes(2);
|
|
25
|
-
}));
|
|
26
|
-
it("should return an array of context response", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
-
const loader = contextLoaderStubBuilder();
|
|
28
|
-
const responses = [
|
|
29
|
-
[{ type: "provideERC20Info", payload: "payload1" }],
|
|
30
|
-
[
|
|
31
|
-
{ type: "provideERC20Info", payload: "payload2" },
|
|
32
|
-
{ type: "setPlugin", payload: "payload3" },
|
|
33
|
-
],
|
|
34
|
-
];
|
|
35
|
-
jest
|
|
36
|
-
.spyOn(loader, "load")
|
|
37
|
-
.mockResolvedValueOnce(responses[0])
|
|
38
|
-
.mockResolvedValueOnce(responses[1]);
|
|
39
|
-
const contextModule = new DefaultContextModule_1.DefaultContextModule({ loaders: [loader, loader] });
|
|
40
|
-
const res = yield contextModule.getContexts({}, {});
|
|
41
|
-
expect(loader.load).toHaveBeenCalledTimes(2);
|
|
42
|
-
expect(res).toEqual(responses.flat());
|
|
43
|
-
}));
|
|
44
|
-
});
|
|
45
|
-
//# sourceMappingURL=DefaultContextModule.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultContextModule.test.js","sourceRoot":"","sources":["../src/DefaultContextModule.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iEAA8D;AAI9D,MAAM,wBAAwB,GAAG,GAAG,EAAE;IACpC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC;AAC7B,CAAC,CAAC;AAEF,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oDAAoD,EAAE,GAAS,EAAE;QAClE,MAAM,MAAM,GAAG,wBAAwB,EAAE,CAAC;QAC1C,MAAM,aAAa,GAAG,IAAI,2CAAoB,CAAC,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;QAE9E,MAAM,aAAa,CAAC,WAAW,CAAC,EAAiB,EAAE,EAAmB,CAAC,CAAC;QAExE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC,CAAA,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAS,EAAE;QAC1D,MAAM,MAAM,GAAG,wBAAwB,EAAE,CAAC;QAC1C,MAAM,SAAS,GAAG;YAChB,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;YACnD;gBACE,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,UAAU,EAAE;gBACjD,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE;aAC3C;SACF,CAAC;QACF,IAAI;aACD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC;aACrB,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;aACnC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,MAAM,aAAa,GAAG,IAAI,2CAAoB,CAAC,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;QAE9E,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,WAAW,CAAC,EAAiB,EAAE,EAAmB,CAAC,CAAC;QAEpF,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAC7C,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IACxC,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export type GetForwardDomainInfosParams = {
|
|
2
|
-
domain: string;
|
|
3
|
-
challenge: string;
|
|
4
|
-
};
|
|
5
|
-
export interface ForwardDomainDataSource {
|
|
6
|
-
getDomainNamePayload(params: GetForwardDomainInfosParams): Promise<string>;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=ForwardDomainDataSource.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ForwardDomainDataSource.d.ts","sourceRoot":"","sources":["../../../src/forward-domain/data/ForwardDomainDataSource.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,oBAAoB,CAAC,MAAM,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ForwardDomainDataSource.js","sourceRoot":"","sources":["../../../src/forward-domain/data/ForwardDomainDataSource.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ForwardDomainDataSource, GetForwardDomainInfosParams } from "./ForwardDomainDataSource";
|
|
2
|
-
export declare class HttpForwardDomainDataSource implements ForwardDomainDataSource {
|
|
3
|
-
getDomainNamePayload({ domain, challenge, }: GetForwardDomainInfosParams): Promise<string>;
|
|
4
|
-
}
|
|
5
|
-
//# sourceMappingURL=HttpForwardDomainDataSource.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpForwardDomainDataSource.d.ts","sourceRoot":"","sources":["../../../src/forward-domain/data/HttpForwardDomainDataSource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAEjG,qBAAa,2BAA4B,YAAW,uBAAuB;IAC5D,oBAAoB,CAAC,EAChC,MAAM,EACN,SAAS,GACV,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC;CAQjD"}
|
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.HttpForwardDomainDataSource = void 0;
|
|
16
|
-
const axios_1 = __importDefault(require("axios"));
|
|
17
|
-
class HttpForwardDomainDataSource {
|
|
18
|
-
getDomainNamePayload(_a) {
|
|
19
|
-
return __awaiter(this, arguments, void 0, function* ({ domain, challenge, }) {
|
|
20
|
-
const response = yield axios_1.default.request({
|
|
21
|
-
method: "GET",
|
|
22
|
-
url: `https://nft.api.live.ledger.com/v1/names/ens/forward/${domain}?challenge=${challenge}`,
|
|
23
|
-
});
|
|
24
|
-
return response.data.payload;
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.HttpForwardDomainDataSource = HttpForwardDomainDataSource;
|
|
29
|
-
//# sourceMappingURL=HttpForwardDomainDataSource.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpForwardDomainDataSource.js","sourceRoot":"","sources":["../../../src/forward-domain/data/HttpForwardDomainDataSource.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAG1B,MAAa,2BAA2B;IACzB,oBAAoB;6DAAC,EAChC,MAAM,EACN,SAAS,GACmB;YAC5B,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,OAAO,CAAsB;gBACxD,MAAM,EAAE,KAAK;gBACb,GAAG,EAAE,wDAAwD,MAAM,cAAc,SAAS,EAAE;aAC7F,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;QAC/B,CAAC;KAAA;CACF;AAZD,kEAYC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ContextLoader } from "../../shared/domain/ContextLoader";
|
|
2
|
-
import { ContextResponse } from "../../shared/model/ContextResponse";
|
|
3
|
-
import { LoaderOptions } from "../../shared/model/LoaderOptions";
|
|
4
|
-
import { Transaction } from "../../shared/model/Transaction";
|
|
5
|
-
import { ForwardDomainDataSource } from "../data/ForwardDomainDataSource";
|
|
6
|
-
export declare class ForwardDomainContextLoader implements ContextLoader {
|
|
7
|
-
private _dataSource;
|
|
8
|
-
constructor(dataSource: ForwardDomainDataSource);
|
|
9
|
-
load(_transaction: Transaction, options: LoaderOptions): Promise<ContextResponse[]>;
|
|
10
|
-
private isDomainValid;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=ForwardDomainContextLoader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ForwardDomainContextLoader.d.ts","sourceRoot":"","sources":["../../../src/forward-domain/domain/ForwardDomainContextLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,qBAAa,0BAA2B,YAAW,aAAa;IAC9D,OAAO,CAAC,WAAW,CAA0B;gBAEjC,UAAU,EAAE,uBAAuB;IAIzC,IAAI,CAAC,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IA8BzF,OAAO,CAAC,aAAa;CAMtB"}
|
|
@@ -1,50 +0,0 @@
|
|
|
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.ForwardDomainContextLoader = void 0;
|
|
13
|
-
class ForwardDomainContextLoader {
|
|
14
|
-
constructor(dataSource) {
|
|
15
|
-
this._dataSource = dataSource;
|
|
16
|
-
}
|
|
17
|
-
load(_transaction, options) {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
var _a;
|
|
20
|
-
const { domain, registry } = ((_a = options.options) === null || _a === void 0 ? void 0 : _a.forwardDomain) || {};
|
|
21
|
-
if (!domain && !registry) {
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
24
|
-
if ((domain && !registry) || (!domain && registry)) {
|
|
25
|
-
throw new Error("[ContextModule] ForwardDomainLoader: Invalid combination of domain and registry. Either both domain and registry should exist");
|
|
26
|
-
}
|
|
27
|
-
if (!this.isDomainValid(domain)) {
|
|
28
|
-
return [
|
|
29
|
-
{
|
|
30
|
-
type: "error",
|
|
31
|
-
error: new Error("[ContextModule] ForwardDomainLoader: invalid domain"),
|
|
32
|
-
},
|
|
33
|
-
];
|
|
34
|
-
}
|
|
35
|
-
const payload = yield this._dataSource.getDomainNamePayload({
|
|
36
|
-
domain: domain,
|
|
37
|
-
challenge: options.challenge,
|
|
38
|
-
});
|
|
39
|
-
return [{ type: "provideDomainName", payload }];
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
// NOTE: duplicata of libs/domain-service/src/utils/index.ts
|
|
43
|
-
isDomainValid(domain) {
|
|
44
|
-
const lengthIsValid = domain.length > 0 && Number(domain.length) < 30;
|
|
45
|
-
const containsOnlyValidChars = new RegExp("^[a-zA-Z0-9\\-\\_\\.]+$").test(domain);
|
|
46
|
-
return lengthIsValid && containsOnlyValidChars;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.ForwardDomainContextLoader = ForwardDomainContextLoader;
|
|
50
|
-
//# sourceMappingURL=ForwardDomainContextLoader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ForwardDomainContextLoader.js","sourceRoot":"","sources":["../../../src/forward-domain/domain/ForwardDomainContextLoader.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA,MAAa,0BAA0B;IAGrC,YAAY,UAAmC;QAC7C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAEK,IAAI,CAAC,YAAyB,EAAE,OAAsB;;;YAC1D,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAA,MAAA,OAAO,CAAC,OAAO,0CAAE,aAAa,KAAI,EAAE,CAAC;YAClE,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACzB,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,QAAQ,CAAC,EAAE,CAAC;gBACnD,MAAM,IAAI,KAAK,CACb,+HAA+H,CAChI,CAAC;YACJ,CAAC;YAED,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,MAAgB,CAAC,EAAE,CAAC;gBAC1C,OAAO;oBACL;wBACE,IAAI,EAAE,OAAgB;wBACtB,KAAK,EAAE,IAAI,KAAK,CAAC,qDAAqD,CAAC;qBACxE;iBACF,CAAC;YACJ,CAAC;YAED,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC;gBAC1D,MAAM,EAAE,MAAO;gBACf,SAAS,EAAE,OAAO,CAAC,SAAS;aAC7B,CAAC,CAAC;YAEH,OAAO,CAAC,EAAE,IAAI,EAAE,mBAA4B,EAAE,OAAO,EAAE,CAAC,CAAC;QAC3D,CAAC;KAAA;IAED,4DAA4D;IACpD,aAAa,CAAC,MAAc;QAClC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QACtE,MAAM,sBAAsB,GAAG,IAAI,MAAM,CAAC,yBAAyB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAElF,OAAO,aAAa,IAAI,sBAAsB,CAAC;IACjD,CAAC;CACF;AA3CD,gEA2CC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ForwardDomainContextLoader.test.d.ts","sourceRoot":"","sources":["../../../src/forward-domain/domain/ForwardDomainContextLoader.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,85 +0,0 @@
|
|
|
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
|
-
const ForwardDomainContextLoader_1 = require("./ForwardDomainContextLoader");
|
|
13
|
-
describe("ForwardDomainContextLoader", () => {
|
|
14
|
-
const transaction = {};
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
jest.restoreAllMocks();
|
|
17
|
-
});
|
|
18
|
-
describe("load function", () => {
|
|
19
|
-
it("should return an empty array when no domain or registry", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
-
const options = {};
|
|
21
|
-
const loader = new ForwardDomainContextLoader_1.ForwardDomainContextLoader({ getDomainNamePayload: jest.fn() });
|
|
22
|
-
const promise = () => loader.load(transaction, options);
|
|
23
|
-
expect(promise()).resolves.toEqual([]);
|
|
24
|
-
}));
|
|
25
|
-
it("should throw an error when no registry", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
-
const options = { options: { forwardDomain: { domain: "test.eth" } } };
|
|
27
|
-
const loader = new ForwardDomainContextLoader_1.ForwardDomainContextLoader({ getDomainNamePayload: jest.fn() });
|
|
28
|
-
const promise = () => loader.load(transaction, options);
|
|
29
|
-
expect(promise()).rejects.toThrow(new Error("[ContextModule] ForwardDomainLoader: Invalid combination of domain and registry. Either both domain and registry should exist"));
|
|
30
|
-
}));
|
|
31
|
-
it("should throw an error when no domain", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
-
const options = { options: { forwardDomain: { registry: "ens" } } };
|
|
33
|
-
const loader = new ForwardDomainContextLoader_1.ForwardDomainContextLoader({ getDomainNamePayload: jest.fn() });
|
|
34
|
-
const promise = () => loader.load(transaction, options);
|
|
35
|
-
expect(promise()).rejects.toThrow(new Error("[ContextModule] ForwardDomainLoader: Invalid combination of domain and registry. Either both domain and registry should exist"));
|
|
36
|
-
}));
|
|
37
|
-
it("should return an error when domain > max length", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
-
const options = {
|
|
39
|
-
options: {
|
|
40
|
-
forwardDomain: {
|
|
41
|
-
domain: "maxlength-maxlength-maxlength-maxlength-maxlength",
|
|
42
|
-
registry: "ens",
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
const loader = new ForwardDomainContextLoader_1.ForwardDomainContextLoader({ getDomainNamePayload: jest.fn() });
|
|
47
|
-
const result = yield loader.load(transaction, options);
|
|
48
|
-
expect(result).toEqual([
|
|
49
|
-
{
|
|
50
|
-
type: "error",
|
|
51
|
-
error: new Error("[ContextModule] ForwardDomainLoader: invalid domain"),
|
|
52
|
-
},
|
|
53
|
-
]);
|
|
54
|
-
}));
|
|
55
|
-
it("should return an error when domain is not valid", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
-
const options = {
|
|
57
|
-
options: { forwardDomain: { domain: "hello👋", registry: "ens" } },
|
|
58
|
-
};
|
|
59
|
-
const loader = new ForwardDomainContextLoader_1.ForwardDomainContextLoader({ getDomainNamePayload: jest.fn() });
|
|
60
|
-
const result = yield loader.load(transaction, options);
|
|
61
|
-
expect(result).toEqual([
|
|
62
|
-
{
|
|
63
|
-
type: "error",
|
|
64
|
-
error: new Error("[ContextModule] ForwardDomainLoader: invalid domain"),
|
|
65
|
-
},
|
|
66
|
-
]);
|
|
67
|
-
}));
|
|
68
|
-
it("should return a payload", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
-
const options = {
|
|
70
|
-
options: { forwardDomain: { domain: "hello.eth", registry: "ens" } },
|
|
71
|
-
};
|
|
72
|
-
const loader = new ForwardDomainContextLoader_1.ForwardDomainContextLoader({
|
|
73
|
-
getDomainNamePayload: () => Promise.resolve("payload"),
|
|
74
|
-
});
|
|
75
|
-
const result = yield loader.load(transaction, options);
|
|
76
|
-
expect(result).toEqual([
|
|
77
|
-
{
|
|
78
|
-
type: "provideDomainName",
|
|
79
|
-
payload: "payload",
|
|
80
|
-
},
|
|
81
|
-
]);
|
|
82
|
-
}));
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
//# sourceMappingURL=ForwardDomainContextLoader.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ForwardDomainContextLoader.test.js","sourceRoot":"","sources":["../../../src/forward-domain/domain/ForwardDomainContextLoader.test.ts"],"names":[],"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CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YACnF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YAEvD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;gBACrB;oBACE,IAAI,EAAE,OAAgB;oBACtB,KAAK,EAAE,IAAI,KAAK,CAAC,qDAAqD,CAAC;iBACxE;aACF,CAAC,CAAC;QACL,CAAC,CAAA,CAAC,CAAC;QAEH,EAAE,CAAC,yBAAyB,EAAE,GAAS,EAAE;YACvC,MAAM,OAAO,GAAG;gBACd,OAAO,EAAE,EAAE,aAAa,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;aACpD,CAAC;YAEnB,MAAM,MAAM,GAAG,IAAI,uDAA0B,CAAC;gBAC5C,oBAAoB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC;aACvD,CAAC,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YAEvD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;gBACrB;oBACE,IAAI,EAAE,mBAA4B;oBAClC,OAAO,EAAE,SAAS;iBACnB;aACF,CAAC,CAAC;QACL,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib/index.d.ts
DELETED
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
|
package/lib/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./DefaultContextModule"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { GetNftInformationsParams, GetSetPluginPayloadParams, NftDataSource } from "./NftDataSource";
|
|
2
|
-
export declare class HttpNftDataSource implements NftDataSource {
|
|
3
|
-
getSetPluginPayload({ chainId, address, selector, }: GetSetPluginPayloadParams): Promise<string>;
|
|
4
|
-
getNftInfosPayload({ chainId, address }: GetNftInformationsParams): Promise<string>;
|
|
5
|
-
}
|
|
6
|
-
//# sourceMappingURL=HttpNftDataSource.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpNftDataSource.d.ts","sourceRoot":"","sources":["../../../src/nft/data/HttpNftDataSource.ts"],"names":[],"mappings":"AACA,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,aAAa,EACd,MAAM,iBAAiB,CAAC;AAEzB,qBAAa,iBAAkB,YAAW,aAAa;IACxC,mBAAmB,CAAC,EAC/B,OAAO,EACP,OAAO,EACP,QAAQ,GACT,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC;IASjC,kBAAkB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,wBAAwB;CAQ/E"}
|
|
@@ -1,38 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.HttpNftDataSource = void 0;
|
|
16
|
-
const axios_1 = __importDefault(require("axios"));
|
|
17
|
-
class HttpNftDataSource {
|
|
18
|
-
getSetPluginPayload(_a) {
|
|
19
|
-
return __awaiter(this, arguments, void 0, function* ({ chainId, address, selector, }) {
|
|
20
|
-
const response = yield axios_1.default.request({
|
|
21
|
-
method: "GET",
|
|
22
|
-
url: `https://nft.api.live.ledger.com/v1/ethereum/${chainId}/contracts/${address}/plugin-selector/${selector}`,
|
|
23
|
-
});
|
|
24
|
-
return response.data.payload;
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
getNftInfosPayload(_a) {
|
|
28
|
-
return __awaiter(this, arguments, void 0, function* ({ chainId, address }) {
|
|
29
|
-
const response = yield axios_1.default.request({
|
|
30
|
-
method: "GET",
|
|
31
|
-
url: `https://nft.api.live.ledger.com/v1/ethereum/${chainId}/contracts/${address}`,
|
|
32
|
-
});
|
|
33
|
-
return response.data.payload;
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.HttpNftDataSource = HttpNftDataSource;
|
|
38
|
-
//# sourceMappingURL=HttpNftDataSource.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpNftDataSource.js","sourceRoot":"","sources":["../../../src/nft/data/HttpNftDataSource.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAO1B,MAAa,iBAAiB;IACf,mBAAmB;6DAAC,EAC/B,OAAO,EACP,OAAO,EACP,QAAQ,GACkB;YAC1B,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,OAAO,CAAsB;gBACxD,MAAM,EAAE,KAAK;gBACb,GAAG,EAAE,+CAA+C,OAAO,cAAc,OAAO,oBAAoB,QAAQ,EAAE;aAC/G,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;QAC/B,CAAC;KAAA;IAEY,kBAAkB;6DAAC,EAAE,OAAO,EAAE,OAAO,EAA4B;YAC5E,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,OAAO,CAAsB;gBACxD,MAAM,EAAE,KAAK;gBACb,GAAG,EAAE,+CAA+C,OAAO,cAAc,OAAO,EAAE;aACnF,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;QAC/B,CAAC;KAAA;CACF;AAtBD,8CAsBC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type GetSetPluginPayloadParams = {
|
|
2
|
-
chainId: number;
|
|
3
|
-
address: string;
|
|
4
|
-
selector: string;
|
|
5
|
-
};
|
|
6
|
-
export type GetNftInformationsParams = {
|
|
7
|
-
chainId: number;
|
|
8
|
-
address: string;
|
|
9
|
-
};
|
|
10
|
-
export interface NftDataSource {
|
|
11
|
-
getNftInfosPayload(params: GetNftInformationsParams): Promise<string>;
|
|
12
|
-
getSetPluginPayload(params: GetSetPluginPayloadParams): Promise<string>;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=NftDataSource.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NftDataSource.d.ts","sourceRoot":"","sources":["../../../src/nft/data/NftDataSource.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACtE,mBAAmB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACzE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NftDataSource.js","sourceRoot":"","sources":["../../../src/nft/data/NftDataSource.ts"],"names":[],"mappings":""}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ContextLoader } from "../../shared/domain/ContextLoader";
|
|
2
|
-
import { ContextResponse } from "../../shared/model/ContextResponse";
|
|
3
|
-
import { LoaderOptions } from "../../shared/model/LoaderOptions";
|
|
4
|
-
import { Transaction } from "../../shared/model/Transaction";
|
|
5
|
-
import { NftDataSource } from "../data/NftDataSource";
|
|
6
|
-
export declare class NftContextLoader implements ContextLoader {
|
|
7
|
-
private _dataSource;
|
|
8
|
-
constructor(dataSource: NftDataSource);
|
|
9
|
-
load(transaction: Transaction, _options: LoaderOptions): Promise<ContextResponse[]>;
|
|
10
|
-
private isSelectorSupported;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=NftContextLoader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NftContextLoader.d.ts","sourceRoot":"","sources":["../../../src/nft/domain/NftContextLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAqBtD,qBAAa,gBAAiB,YAAW,aAAa;IACpD,OAAO,CAAC,WAAW,CAAgB;gBAEvB,UAAU,EAAE,aAAa;IAI/B,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAgDzF,OAAO,CAAC,mBAAmB;CAG5B"}
|
|
@@ -1,79 +0,0 @@
|
|
|
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.NftContextLoader = void 0;
|
|
13
|
-
var ERC721_SUPPORTED_SELECTOR;
|
|
14
|
-
(function (ERC721_SUPPORTED_SELECTOR) {
|
|
15
|
-
ERC721_SUPPORTED_SELECTOR["Approve"] = "0x095ea7b3";
|
|
16
|
-
ERC721_SUPPORTED_SELECTOR["SetApprovalForAll"] = "0xa22cb465";
|
|
17
|
-
ERC721_SUPPORTED_SELECTOR["TransferFrom"] = "0x23b872dd";
|
|
18
|
-
ERC721_SUPPORTED_SELECTOR["SafeTransferFrom"] = "0x42842e0e";
|
|
19
|
-
ERC721_SUPPORTED_SELECTOR["SafeTransferFromWithData"] = "0xb88d4fde";
|
|
20
|
-
})(ERC721_SUPPORTED_SELECTOR || (ERC721_SUPPORTED_SELECTOR = {}));
|
|
21
|
-
var ERC1155_SUPPORTED_SELECTOR;
|
|
22
|
-
(function (ERC1155_SUPPORTED_SELECTOR) {
|
|
23
|
-
ERC1155_SUPPORTED_SELECTOR["SetApprovalForAll"] = "0xa22cb465";
|
|
24
|
-
ERC1155_SUPPORTED_SELECTOR["SafeTransferFrom"] = "0xf242432a";
|
|
25
|
-
ERC1155_SUPPORTED_SELECTOR["SafeBatchTransferFrom"] = "0x2eb2c2d6";
|
|
26
|
-
})(ERC1155_SUPPORTED_SELECTOR || (ERC1155_SUPPORTED_SELECTOR = {}));
|
|
27
|
-
const SUPPORTED_SELECTORS = [
|
|
28
|
-
...Object.values(ERC721_SUPPORTED_SELECTOR),
|
|
29
|
-
...Object.values(ERC1155_SUPPORTED_SELECTOR),
|
|
30
|
-
];
|
|
31
|
-
class NftContextLoader {
|
|
32
|
-
constructor(dataSource) {
|
|
33
|
-
this._dataSource = dataSource;
|
|
34
|
-
}
|
|
35
|
-
load(transaction, _options) {
|
|
36
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
const responses = [];
|
|
38
|
-
if (!transaction.to || !transaction.data || transaction.data === "0x") {
|
|
39
|
-
return [];
|
|
40
|
-
}
|
|
41
|
-
const selector = transaction.data.slice(0, 10);
|
|
42
|
-
if (!this.isSelectorSupported(selector)) {
|
|
43
|
-
return [];
|
|
44
|
-
}
|
|
45
|
-
// EXAMPLE:
|
|
46
|
-
// https://nft.api.live.ledger.com/v1/ethereum/1/contracts/0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D/plugin-selector/0x095ea7b3
|
|
47
|
-
const setPluginPayload = yield this._dataSource.getSetPluginPayload({
|
|
48
|
-
chainId: transaction.chainId,
|
|
49
|
-
address: transaction.to,
|
|
50
|
-
selector,
|
|
51
|
-
});
|
|
52
|
-
if (!setPluginPayload) {
|
|
53
|
-
return [
|
|
54
|
-
{
|
|
55
|
-
type: "error",
|
|
56
|
-
error: new Error("[ContextModule] NftLoader: unexpected empty response"),
|
|
57
|
-
},
|
|
58
|
-
];
|
|
59
|
-
}
|
|
60
|
-
responses.push({ type: "setPlugin", payload: setPluginPayload });
|
|
61
|
-
const nftInformationsPayload = yield this._dataSource.getNftInfosPayload({
|
|
62
|
-
chainId: transaction.chainId,
|
|
63
|
-
address: transaction.to,
|
|
64
|
-
});
|
|
65
|
-
if (!nftInformationsPayload) {
|
|
66
|
-
return [
|
|
67
|
-
{ type: "error", error: new Error("[ContextModule] NftLoader: no nft metadata") },
|
|
68
|
-
];
|
|
69
|
-
}
|
|
70
|
-
responses.push({ type: "provideNFTInformation", payload: nftInformationsPayload });
|
|
71
|
-
return responses;
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
isSelectorSupported(selector) {
|
|
75
|
-
return Object.values(SUPPORTED_SELECTORS).includes(selector);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.NftContextLoader = NftContextLoader;
|
|
79
|
-
//# sourceMappingURL=NftContextLoader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NftContextLoader.js","sourceRoot":"","sources":["../../../src/nft/domain/NftContextLoader.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA,IAAK,yB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E,CAAC;gBACtB,OAAO;oBACL;wBACE,IAAI,EAAE,OAAgB;wBACtB,KAAK,EAAE,IAAI,KAAK,CAAC,sDAAsD,CAAC;qBACzE;iBACF,CAAC;YACJ,CAAC;YAED,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC;YAEjE,MAAM,sBAAsB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC;gBACvE,OAAO,EAAE,WAAW,CAAC,OAAO;gBAC5B,OAAO,EAAE,WAAW,CAAC,EAAE;aACxB,CAAC,CAAC;YAEH,IAAI,CAAC,sBAAsB,EAAE,CAAC;gBAC5B,OAAO;oBACL,EAAE,IAAI,EAAE,OAAgB,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,4CAA4C,CAAC,EAAE;iBAC3F,CAAC;YACJ,CAAC;YAED,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC,CAAC;YAEnF,OAAO,SAAS,CAAC;QACnB,CAAC;KAAA;IAEO,mBAAmB,CAAC,QAAuB;QACjD,OAAO,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC/D,CAAC;CACF;AA1DD,4CA0DC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NftContextLoader.test.d.ts","sourceRoot":"","sources":["../../../src/nft/domain/NftContextLoader.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,113 +0,0 @@
|
|
|
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
|
-
const NftContextLoader_1 = require("./NftContextLoader");
|
|
13
|
-
describe("NftContextLoader", () => {
|
|
14
|
-
const spyGetNftInfosPayload = jest.fn();
|
|
15
|
-
const spyGetPluginPayload = jest.fn();
|
|
16
|
-
let mockDataSource;
|
|
17
|
-
let loader;
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
jest.restoreAllMocks();
|
|
20
|
-
mockDataSource = {
|
|
21
|
-
getNftInfosPayload: spyGetNftInfosPayload,
|
|
22
|
-
getSetPluginPayload: spyGetPluginPayload,
|
|
23
|
-
};
|
|
24
|
-
loader = new NftContextLoader_1.NftContextLoader(mockDataSource);
|
|
25
|
-
});
|
|
26
|
-
describe("load function", () => {
|
|
27
|
-
it("should return an empty array if no dest", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
-
const options = {};
|
|
29
|
-
const transaction = { to: undefined, data: "0x01" };
|
|
30
|
-
const result = yield loader.load(transaction, options);
|
|
31
|
-
expect(result).toEqual([]);
|
|
32
|
-
}));
|
|
33
|
-
it("should return an empty array if undefined data", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
const options = {};
|
|
35
|
-
const transaction = {
|
|
36
|
-
to: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
37
|
-
data: undefined,
|
|
38
|
-
};
|
|
39
|
-
const result = yield loader.load(transaction, options);
|
|
40
|
-
expect(result).toEqual([]);
|
|
41
|
-
}));
|
|
42
|
-
it("should return an empty array if empty data", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
-
const options = {};
|
|
44
|
-
const transaction = {
|
|
45
|
-
to: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
46
|
-
data: "0x",
|
|
47
|
-
};
|
|
48
|
-
const result = yield loader.load(transaction, options);
|
|
49
|
-
expect(result).toEqual([]);
|
|
50
|
-
}));
|
|
51
|
-
it("should return an empty array if selector not supported", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
-
const options = {};
|
|
53
|
-
const transaction = {
|
|
54
|
-
to: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
55
|
-
data: "0x095ea7b20000000000000",
|
|
56
|
-
};
|
|
57
|
-
const result = yield loader.load(transaction, options);
|
|
58
|
-
expect(result).toEqual([]);
|
|
59
|
-
}));
|
|
60
|
-
it("should return an error when no plugin response", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
-
const options = {};
|
|
62
|
-
const transaction = {
|
|
63
|
-
to: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
64
|
-
data: "0x095ea7b30000000000000",
|
|
65
|
-
};
|
|
66
|
-
spyGetPluginPayload.mockResolvedValueOnce(undefined);
|
|
67
|
-
const result = yield loader.load(transaction, options);
|
|
68
|
-
expect(result).toEqual([
|
|
69
|
-
expect.objectContaining({
|
|
70
|
-
type: "error",
|
|
71
|
-
error: new Error("[ContextModule] NftLoader: unexpected empty response"),
|
|
72
|
-
}),
|
|
73
|
-
]);
|
|
74
|
-
}));
|
|
75
|
-
it("should return an error when no nft data response", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
76
|
-
const options = {};
|
|
77
|
-
const transaction = {
|
|
78
|
-
to: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
79
|
-
data: "0x095ea7b30000000000000",
|
|
80
|
-
};
|
|
81
|
-
spyGetPluginPayload.mockResolvedValueOnce("payload1");
|
|
82
|
-
spyGetNftInfosPayload.mockResolvedValueOnce(undefined);
|
|
83
|
-
const result = yield loader.load(transaction, options);
|
|
84
|
-
expect(result).toEqual([
|
|
85
|
-
expect.objectContaining({
|
|
86
|
-
type: "error",
|
|
87
|
-
error: new Error("[ContextModule] NftLoader: no nft metadata"),
|
|
88
|
-
}),
|
|
89
|
-
]);
|
|
90
|
-
}));
|
|
91
|
-
it("should return a response", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
-
const options = {};
|
|
93
|
-
const transaction = {
|
|
94
|
-
to: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
95
|
-
data: "0x095ea7b30000000000000",
|
|
96
|
-
};
|
|
97
|
-
spyGetPluginPayload.mockResolvedValueOnce("payload1");
|
|
98
|
-
spyGetNftInfosPayload.mockResolvedValueOnce("payload2");
|
|
99
|
-
const result = yield loader.load(transaction, options);
|
|
100
|
-
expect(result).toEqual([
|
|
101
|
-
{
|
|
102
|
-
type: "setPlugin",
|
|
103
|
-
payload: "payload1",
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
type: "provideNFTInformation",
|
|
107
|
-
payload: "payload2",
|
|
108
|
-
},
|
|
109
|
-
]);
|
|
110
|
-
}));
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
//# sourceMappingURL=NftContextLoader.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NftContextLoader.test.js","sourceRoot":"","sources":["../../../src/nft/domain/NftContextLoader.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAGA,yDAAsD;AAEtD,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,MAAM,qBAAqB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IACxC,MAAM,mBAAmB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IACtC,IAAI,cAA6B,CAAC;IAClC,IAAI,MAAwB,CAAC;IAE7B,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,cAAc,GAAG;YACf,kBAAkB,EAAE,qBAAqB;YACzC,mBAAmB,EAAE,mBAAmB;SACzC,CAAC;QACF,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CAAC,OAAO,CAAC;gBACrB,MAAM,CAAC,gBAAgB,CAAC;oBACtB,IAAI,EAAE,OAAgB;oBACtB,KAAK,EAAE,IAAI,KAAK,CAAC,4CAA4C,CAAC;iBAC/D,CAAC;aACH,CAAC,CAAC;QACL,CAAC,CAAA,CAAC,CAAC;QAEH,EAAE,CAAC,0BAA0B,EAAE,GAAS,EAAE;YACxC,MAAM,OAAO,GAAG,EAAmB,CAAC;YACpC,MAAM,WAAW,GAAG;gBAClB,EAAE,EAAE,4CAA4C;gBAChD,IAAI,EAAE,yBAAyB;aACN,CAAC;YAC5B,mBAAmB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;YACtD,qBAAqB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;YAExD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YAEvD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;gBACrB;oBACE,IAAI,EAAE,WAAoB;oBAC1B,OAAO,EAAE,UAAU;iBACpB;gBACD;oBACE,IAAI,EAAE,uBAAgC;oBACtC,OAAO,EAAE,UAAU;iBACpB;aACF,CAAC,CAAC;QACL,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ContextResponse } from "../model/ContextResponse";
|
|
2
|
-
import { LoaderOptions } from "../model/LoaderOptions";
|
|
3
|
-
import { Transaction } from "../model/Transaction";
|
|
4
|
-
export type ContextLoader = {
|
|
5
|
-
load: (transaction: Transaction, options: LoaderOptions) => Promise<ContextResponse[]>;
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=ContextLoader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContextLoader.d.ts","sourceRoot":"","sources":["../../../src/shared/domain/ContextLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;CACxF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContextLoader.js","sourceRoot":"","sources":["../../../src/shared/domain/ContextLoader.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
type ContextSuccess = {
|
|
2
|
-
type: "provideERC20TokenInformation" | "provideNFTInformation" | "provideDomainName" | "setPlugin" | "setExternalPlugin";
|
|
3
|
-
payload: string;
|
|
4
|
-
};
|
|
5
|
-
type ContextError = {
|
|
6
|
-
type: "error";
|
|
7
|
-
error: Error;
|
|
8
|
-
};
|
|
9
|
-
export type ContextResponse = ContextSuccess | ContextError;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=ContextResponse.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContextResponse.d.ts","sourceRoot":"","sources":["../../../src/shared/model/ContextResponse.ts"],"names":[],"mappings":"AAAA,KAAK,cAAc,GAAG;IACpB,IAAI,EACA,8BAA8B,GAC9B,uBAAuB,GACvB,mBAAmB,GACnB,WAAW,GACX,mBAAmB,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,YAAY,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContextResponse.js","sourceRoot":"","sources":["../../../src/shared/model/ContextResponse.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LoaderOptions.d.ts","sourceRoot":"","sources":["../../../src/shared/model/LoaderOptions.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,KAAK,CAAA;SAAE,CAAA;KAAE,CAAC;CACnE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LoaderOptions.js","sourceRoot":"","sources":["../../../src/shared/model/LoaderOptions.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.d.ts","sourceRoot":"","sources":["../../../src/shared/model/Transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../src/shared/model/Transaction.ts"],"names":[],"mappings":""}
|