-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
7,275 additions
and
8,132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
node_modules | ||
lib | ||
.parcel-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* Data types supported by JSON format | ||
*/ | ||
export type JsonType = 'string' | 'number' | 'object' | 'array' | 'boolean' | 'null'; | ||
export enum StandardInterfaceId { | ||
NEP141 = "nep141", | ||
NEP145 = "nep145", | ||
NEP148 = "nep148", | ||
NEP171 = "nep171", | ||
NEP177 = "nep177", | ||
NEP178 = "nep178", | ||
NEP199 = "nep199", | ||
NEP330 = "nep330" | ||
} | ||
/** | ||
* Well-known smart contract interface specification | ||
*/ | ||
export interface StandardInterface { | ||
/** Unique interface ID */ | ||
id: StandardInterfaceId; | ||
/** Human-readable interface name */ | ||
name: string; | ||
/** Methods provided by interface */ | ||
methods: StandardInterfaceMethod[]; | ||
} | ||
export interface StandardInterfaceArgument { | ||
name: string; | ||
/** | ||
* An argument can support one or multiple types | ||
* (e.g. Rust's `Option<String>` becomes `['string', 'null']`) | ||
*/ | ||
type: JsonType | JsonType[]; | ||
} | ||
export interface StandardInterfaceMethod { | ||
name: string; | ||
args: StandardInterfaceArgument[]; | ||
} | ||
/** | ||
* Mapping interface ID to interface specification | ||
*/ | ||
export const interfaces: Readonly<Record<StandardInterfaceId, StandardInterface>>; | ||
/** | ||
* Guesses which standards a contract _probably_ implements based on exported | ||
* method names. | ||
* | ||
* @param methodNames Exported method names | ||
* @returns Interfaces the contract probably implements, as well as which | ||
* methods likely constitute which interfaces | ||
*/ | ||
export function getProbableInterfaces(methodNames: string[]): { | ||
probableInterfaces: StandardInterfaceId[]; | ||
byMethod: Record<string, StandardInterfaceId[]>; | ||
}; | ||
/** | ||
* Parse base64-encoded WASM into AST | ||
* | ||
* @param wasmb64 base64-encoded WASM binary | ||
* @returns WASM abstract syntax tree | ||
*/ | ||
export function parseWasm(wasmb64: string): any; | ||
/** | ||
* Extracts exported functions from smart contract | ||
* | ||
* @param code_base64 Base64-encoded WASM binary (e.g. obtained from | ||
* `near-api-js`) | ||
* @returns List of exported function names | ||
*/ | ||
export function getMethodNames(code_base64: string): string[]; | ||
export interface ParsedContract { | ||
/** | ||
* Standard interfaces the original contract is likely to support | ||
*/ | ||
probableInterfaces: StandardInterfaceId[]; | ||
/** | ||
* Maps method names to the ID of the interface they are likey to constitute | ||
*/ | ||
byMethod: Record<string, StandardInterfaceId[]>; | ||
/** | ||
* Names of functions exported from the original contract | ||
*/ | ||
methodNames: string[]; | ||
} | ||
export function parseContract(code_base64: string): ParsedContract; | ||
|
||
//# sourceMappingURL=bundle.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"mappings":"AAAA;;GAEG;AACH,uBACI,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,SAAS,GACT,MAAM,CAAC;ACPX;IACE,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAED;;GAEG;AACH;IACE,0BAA0B;IAC1B,EAAE,EAAE,mBAAmB,CAAC;IACxB,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,OAAO,EAAE,uBAAuB,EAAE,CAAC;CACpC;AAED;IACE,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,IAAI,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAAC;CAC7B;AAED;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,yBAAyB,EAAE,CAAC;CACnC;AAED;;GAEG;AACH,OAAO,MAAM,YAAY,QAAQ,CAC/B,MAAM,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CAkL9C,CAAC;AC3NH;;;;;;;GAOG;AACH,sCAAsC,WAAW,EAAE,MAAM,EAAE,GAAG;IAC5D,kBAAkB,EAAE,mBAAmB,EAAE,CAAC;IAC1C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC;CACjD,CAeA;ACLD;;;;;GAKG;AACH,0BAA0B,OAAO,EAAE,MAAM,GAAG,GAAG,CAE9C;AC7BD;;;;;;GAMG;AACH,+BAA+B,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAO5D;ACdD;IACE;;OAEG;IACH,kBAAkB,EAAE,mBAAmB,EAAE,CAAC;IAC1C;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC;IAChD;;OAEG;IACH,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;ACXD,8BAA8B,WAAW,EAAE,MAAM,GAAG,cAAc,CAOjE","sources":["src/src/JsonType.ts","src/src/interfaces.ts","src/src/getProbableInterfaces.ts","src/src/parseWasm.ts","src/src/methods.ts","src/src/ParsedContract.ts","src/src/parseContract.ts","src/src/index.ts","src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,"export * from './getProbableInterfaces';\nexport * from './interfaces';\nexport * from './JsonType';\nexport * from './methods';\nexport * from './parseContract';\nexport * from './ParsedContract';\nexport * from './parseWasm';\n"],"names":[],"version":3,"file":"bundle.d.ts.map"} |
Oops, something went wrong.