no-yolo-signatures
Advanced tools
Comparing version
@@ -5,3 +5,4 @@ import { Address, Transaction, TokenList, GenericAddressList } from "./types"; | ||
GenericAddressInfo = "genericAddressInfo", | ||
ContextInfo = "contextInfo" | ||
ContextInfo = "contextInfo", | ||
GenericWarningInfo = "genericWarningInfo" | ||
} | ||
@@ -29,2 +30,11 @@ export declare enum ContextInfoType { | ||
} | ||
export interface GenericWarningInfo { | ||
type: AddressInfoType.GenericWarningInfo; | ||
chainId: number; | ||
address: Address; | ||
name: string; | ||
description: string; | ||
logoURI: string; | ||
source: string; | ||
} | ||
interface ContextAddressInfo { | ||
@@ -34,3 +44,3 @@ type: AddressInfoType.ContextInfo; | ||
} | ||
export declare type AddressInfo = TokenAddressInfo | GenericAddressInfo | ContextAddressInfo; | ||
export declare type AddressInfo = TokenAddressInfo | GenericAddressInfo | ContextAddressInfo | GenericWarningInfo; | ||
export declare type AddressFetchResult = { | ||
@@ -48,5 +58,6 @@ [key: Address]: Array<AddressInfo>; | ||
GenericAddressList = "GenericAddressList", | ||
GenericWarningList = "GenericWarningList", | ||
Context = "Context" | ||
} | ||
export declare type BuiltInAddressInfoFetcher = TokenListAddressInfoFetcher | GenericAddressListInfoFetcher | ContextAddressInfoFetcher; | ||
export declare type BuiltInAddressInfoFetcher = TokenListAddressInfoFetcher | GenericAddressListInfoFetcher | ContextAddressInfoFetcher | GenericWarningListInfoFetcher; | ||
export declare class TokenListAddressInfoFetcher implements AddressInfoFetcher { | ||
@@ -68,2 +79,10 @@ readonly tokenList: TokenList; | ||
} | ||
export declare class GenericWarningListInfoFetcher implements AddressInfoFetcher { | ||
readonly addressList: GenericAddressList; | ||
readonly source: string; | ||
readonly type = BuiltInAddressInfoFetchersType.GenericWarningList; | ||
static fromURL(url: string): Promise<GenericWarningListInfoFetcher>; | ||
constructor(addressList: GenericAddressList, source: string); | ||
fetchInfo(address: Address): Promise<Array<AddressInfo>>; | ||
} | ||
export declare class ContextAddressInfoFetcher implements AddressInfoFetcher { | ||
@@ -70,0 +89,0 @@ readonly type = BuiltInAddressInfoFetchersType.Context; |
@@ -53,3 +53,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getAddressInfoFetchersForChainId = exports.ContextAddressInfoFetcher = exports.GenericAddressListInfoFetcher = exports.TokenListAddressInfoFetcher = exports.BuiltInAddressInfoFetchersType = exports.ContextInfoType = exports.AddressInfoType = void 0; | ||
exports.getAddressInfoFetchersForChainId = exports.ContextAddressInfoFetcher = exports.GenericWarningListInfoFetcher = exports.GenericAddressListInfoFetcher = exports.TokenListAddressInfoFetcher = exports.BuiltInAddressInfoFetchersType = exports.ContextInfoType = exports.AddressInfoType = void 0; | ||
var _1 = require("."); | ||
@@ -62,2 +62,3 @@ var cross_fetch_1 = __importDefault(require("cross-fetch")); | ||
AddressInfoType["ContextInfo"] = "contextInfo"; | ||
AddressInfoType["GenericWarningInfo"] = "genericWarningInfo"; | ||
})(AddressInfoType = exports.AddressInfoType || (exports.AddressInfoType = {})); | ||
@@ -72,2 +73,3 @@ var ContextInfoType; | ||
BuiltInAddressInfoFetchersType["GenericAddressList"] = "GenericAddressList"; | ||
BuiltInAddressInfoFetchersType["GenericWarningList"] = "GenericWarningList"; | ||
BuiltInAddressInfoFetchersType["Context"] = "Context"; | ||
@@ -139,2 +141,34 @@ })(BuiltInAddressInfoFetchersType = exports.BuiltInAddressInfoFetchersType || (exports.BuiltInAddressInfoFetchersType = {})); | ||
exports.GenericAddressListInfoFetcher = GenericAddressListInfoFetcher; | ||
var GenericWarningListInfoFetcher = /** @class */ (function () { | ||
function GenericWarningListInfoFetcher(addressList, source) { | ||
this.addressList = addressList; | ||
this.source = source; | ||
this.type = BuiltInAddressInfoFetchersType.GenericWarningList; | ||
} | ||
GenericWarningListInfoFetcher.fromURL = function (url) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var resp, json; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, (0, cross_fetch_1.default)(url)]; | ||
case 1: | ||
resp = _a.sent(); | ||
return [4 /*yield*/, resp.json()]; | ||
case 2: | ||
json = _a.sent(); | ||
return [2 /*return*/, new this(json, url)]; | ||
} | ||
}); | ||
}); | ||
}; | ||
GenericWarningListInfoFetcher.prototype.fetchInfo = function (address) { | ||
var match = this.addressList.addresses.find(function (_) { return _.address === address; }); | ||
if (!match) { | ||
return Promise.resolve([]); | ||
} | ||
return Promise.resolve([__assign(__assign({ type: AddressInfoType.GenericWarningInfo }, match), { source: this.source })]); | ||
}; | ||
return GenericWarningListInfoFetcher; | ||
}()); | ||
exports.GenericWarningListInfoFetcher = GenericWarningListInfoFetcher; | ||
var ContextAddressInfoFetcher = /** @class */ (function () { | ||
@@ -141,0 +175,0 @@ function ContextAddressInfoFetcher() { |
{ | ||
"name": "no-yolo-signatures", | ||
"version": "0.0.1-alpha4", | ||
"version": "0.0.1-alpha5", | ||
"description": "Tooling to discourage yolo tx signing", | ||
@@ -5,0 +5,0 @@ "author": "Nam Chu Hoai", |
Sorry, the diff of this file is not supported yet
136649
2.41%2117
2.62%