Skip to content

Commit 1223fa0

Browse files
committed
feat(add global): add global
1 parent 874090b commit 1223fa0

File tree

17 files changed

+1147
-6
lines changed

17 files changed

+1147
-6
lines changed

dist/anyweb-js-sdk.umd.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/anyweb-js-sdk.umd.min.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/package.json

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
{
2+
"name": "@idealight-labs/anyweb-js-sdk",
3+
"description": "AnyWeb JavaScript Software Development Kit",
4+
"version": "1.3.3",
5+
"license": "LGPL-3.0",
6+
"author": "common@idealight.ltd",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/IdeaLightLabs/AnyWeb-JS-SDK.git"
10+
},
11+
"keywords": [
12+
"anyweb",
13+
"sdk"
14+
],
15+
"main": "dist/src/index.js",
16+
"types": "dist/src/index.d.ts",
17+
"browser": "dist/src/index.js",
18+
"browserify-browser": {
19+
"secp256k1": "secp256k1/elliptic"
20+
},
21+
"files": [
22+
"dist",
23+
"src",
24+
"lib",
25+
"types",
26+
"anyweb-js-sdk.umd.min.js"
27+
],
28+
"browserslit": "cover 99.5%",
29+
"dependencies": {
30+
"@commitlint/config-conventional": "^16.0.0",
31+
"@conflux-dev/conflux-address-js": "^1.3.12",
32+
"abi-util-lite": "^0.1.0",
33+
"big.js": "^5.2.2",
34+
"commander": "^8.0.0",
35+
"conventional-changelog-cli": "^2.2.2",
36+
"js-conflux-sdk": "^2.0.0",
37+
"keccak": "^2.0.0",
38+
"node-forge": "^1.2.1",
39+
"rlp": "^2.2.7",
40+
"scrypt-js": "^3.0.1",
41+
"secp256k1": "^3.7.1",
42+
"superagent": "^6.1.0",
43+
"typescript": "^4.5.5",
44+
"websocket": "^1.0.31"
45+
},
46+
"devDependencies": {
47+
"@babel/core": "^7.8.4",
48+
"@babel/plugin-transform-runtime": "^7.8.3",
49+
"@babel/preset-env": "^7.8.4",
50+
"@babel/preset-typescript": "^7.16.7",
51+
"@babel/runtime": "^7.8.4",
52+
"@commitlint/cli": "^16.1.0",
53+
"@commitlint/config-angular": "^16.0.0",
54+
"@types/jest": "^27.4.0",
55+
"@types/node": "^14.0.23",
56+
"@types/node-forge": "^1.0.0",
57+
"@typescript-eslint/eslint-plugin": "^5.10.2",
58+
"@typescript-eslint/parser": "^5.10.2",
59+
"babel-plugin-lodash": "^3.3.4",
60+
"babelify": "^10.0.0",
61+
"browserify": "^16.5.1",
62+
"commitizen": "^4.2.4",
63+
"concurrently": "^5.1.0",
64+
"cz-conventional-changelog": "^3.3.0",
65+
"eslint": "^7.12.0",
66+
"eslint-config-airbnb-base": "^14.0.0",
67+
"eslint-config-prettier": "^8.3.0",
68+
"eslint-plugin-import": "^2.18.2",
69+
"eslint-plugin-prettier": "^4.0.0",
70+
"exorcist": "^1.0.1",
71+
"fs-extra": "^8.1.0",
72+
"husky": "^7.0.0",
73+
"jest": "^27.4.7",
74+
"jsbi": "^3.1.4",
75+
"jsdoc-to-markdown": "^7.1.0",
76+
"minify-stream": "^2.0.1",
77+
"mold-source-map": "^0.4.0",
78+
"prettier": "^2.5.1",
79+
"solc": "^0.6.10",
80+
"standard-version": "^9.3.2",
81+
"ts-jest": "^27.1.3",
82+
"tsify": "^5.0.4",
83+
"typedoc": "^0.22.11",
84+
"typedoc-plugin-markdown": "^3.11.12"
85+
},
86+
"resolutions": {
87+
"tinyify/acorn-node/acorn": "7.1.1",
88+
"eslint/espree/acorn": "7.1.1",
89+
"tinyify/unassertify/unassert/acorn": "7.1.1",
90+
"**/minimist": "^1.2.3",
91+
"**/kind-of": "^6.0.3",
92+
"**/elliptic": "^6.5.3",
93+
"**/lodash": "^4.17.20",
94+
"**/babel-jest": "^26.6.0",
95+
"jest/jest-cli/jest-config/jest-environment-jsdom/jsdom/acorn-globals/acorn": "6.4.1"
96+
},
97+
"scripts": {
98+
"lint": "eslint ./src ./test",
99+
"lint:fix": "eslint ./src ./test --fix",
100+
"build": "node scripts/build-frontend.js",
101+
"document": "typedoc --plugin typedoc-plugin-markdown --out docs/api/ src/index.ts",
102+
"prepublishOnly": "npm run build:lib && npm run build",
103+
"test": "jest --coverage",
104+
"build:lib": "tsc",
105+
"dev": "tsc --watch",
106+
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
107+
"commit": "git cz",
108+
"release": "standard-version --release-as",
109+
"prepare": "husky install"
110+
},
111+
"config": {
112+
"commitizen": {
113+
"path": "./node_modules/cz-conventional-changelog"
114+
}
115+
},
116+
"bugs": {
117+
"url": "https://github.com/IdeaLightLabs/AnyWeb-JS-SDK/issues"
118+
},
119+
"homepage": "https://github.com/IdeaLightLabs/AnyWeb-JS-SDK#readme",
120+
"directories": {
121+
"example": "example",
122+
"lib": "lib",
123+
"test": "test"
124+
}
125+
}

dist/src/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { Provider } from './provider';
2+
export { Provider };

dist/src/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.Provider = void 0;
4+
const provider_1 = require("./provider");
5+
Object.defineProperty(exports, "Provider", { enumerable: true, get: function () { return provider_1.Provider; } });
6+
module.exports = {
7+
Provider: provider_1.Provider,
8+
};

dist/src/interface/provider.d.ts

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/**
2+
* @author Littleor <me@littleor.cn>
3+
* @since 2022/2/4
4+
*/
5+
import { ConsoleLike } from '../utils/types';
6+
/**
7+
* Request Args
8+
*/
9+
export interface IRequestArguments {
10+
readonly method: string;
11+
readonly params?: unknown;
12+
readonly chainId?: number;
13+
}
14+
export interface IBaseProviderOptions {
15+
logger?: ConsoleLike;
16+
appId: string;
17+
global?: boolean;
18+
}
19+
/**
20+
* Base Provider
21+
*/
22+
export interface IProvider {
23+
/**
24+
* Request
25+
* @param args {IRequestArguments} Request Arguments: {method, params}
26+
* @returns {Promise<any>}
27+
*/
28+
request(args: IRequestArguments): Promise<unknown>;
29+
/**
30+
* monitor information
31+
* @param type {string} monitor type
32+
* @param listener {Function} callback
33+
*/
34+
on(type: string, listener: (...args: any[]) => void): void;
35+
}
36+
/**
37+
* @author Littleor <me@littleor.cn>
38+
* @since 2022/2/18
39+
*/
40+
export interface IAuthResult {
41+
chainId: number;
42+
networkId: number;
43+
address: string[];
44+
url: string;
45+
code: string;
46+
scopes: string[];
47+
}
48+
export interface IProviderRpcError extends Error {
49+
message: string;
50+
code: number;
51+
data?: unknown;
52+
}
53+
export interface IProviderConnectInfo {
54+
readonly chainId: string;
55+
}
56+
export interface IProviderMessage {
57+
readonly type: string;
58+
readonly data: unknown;
59+
}
60+
export declare type IMethodType = 'account' | 'createContract' | 'callContract' | 'createTransaction' | 'importAccount' | 'exitAccounts' | 'signTypedData' | 'logout' | 'checkAuth' | 'checkLogin' | 'home' | 'unknownType' | 'identify' | 'checkIdentify';
61+
export interface IIframeOptions {
62+
appId: string;
63+
params: string;
64+
chainId: number;
65+
scopes?: string[];
66+
waitResult?: boolean;
67+
silence?: boolean;
68+
}
69+
export interface IIframeData {
70+
type: 'event' | 'callback' | 'router' | 'default';
71+
data: unknown;
72+
success?: boolean;
73+
message?: string;
74+
code: number;
75+
}
76+
export interface IIframeEventData {
77+
type: 'changeNetwork' | 'changeChain';
78+
data: unknown;
79+
}
80+
export declare type IRequestParams = IRequestParamsAccounts | {
81+
payload: IPayload;
82+
gatewayPayload?: IGatewayPayload;
83+
} | IPayload;
84+
export interface IRequestParamsAccounts {
85+
scopes: string[];
86+
[key: string]: unknown;
87+
}
88+
export interface IPayload {
89+
to: string;
90+
[key: string]: unknown;
91+
}
92+
export interface IGatewayPayload {
93+
[key: string]: unknown;
94+
}

dist/src/interface/provider.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });

dist/src/provider.d.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**
2+
* @author Littleor <me@littleor.cn>
3+
* @since 2022/2/2
4+
*/
5+
import { IBaseProviderOptions, IProvider, IProviderConnectInfo, IProviderMessage, IProviderRpcError, IRequestArguments } from './interface/provider';
6+
import { ConsoleLike } from './utils/types';
7+
/**
8+
* AnyWeb Provider
9+
* @class Provider
10+
* @author Littleor
11+
* @since 2020/2/2
12+
* @example
13+
* const provider = new Provider()
14+
*/
15+
export declare class Provider implements IProvider {
16+
logger?: ConsoleLike;
17+
readonly appId: string;
18+
private chainId;
19+
private static instance;
20+
static ready: boolean;
21+
appUrl: string | undefined;
22+
events: {
23+
onConnect?: (connectInfo: IProviderConnectInfo) => void;
24+
onDisconnect?: (error: IProviderRpcError) => void;
25+
onChainChanged?: (chainId: string) => void;
26+
onAccountsChanged?: (accounts: string[]) => void;
27+
onMessage?: (message: IProviderMessage) => void;
28+
onNetworkChanged?: (networkId: string) => void;
29+
onReady?: () => void;
30+
};
31+
constructor({ logger, appId, global }: IBaseProviderOptions, appUrl?: string);
32+
static getInstance(params?: IBaseProviderOptions): Provider;
33+
/**
34+
* Deprecated: use `request` instead
35+
* @param arg
36+
*/
37+
send(...arg: any[]): Promise<unknown>;
38+
/**
39+
* Deprecated: use `request` instead
40+
* @param arg
41+
*/
42+
call(...arg: any[]): Promise<unknown>;
43+
/**
44+
* Submits an RPC request
45+
* @param args {IRequestArguments} Request Arguments: {method, params}
46+
* @returns {Promise<any>}
47+
* @example
48+
* const result = await provider.request({ method: 'cfx_sendTransaction', params})
49+
*/
50+
request(args: IRequestArguments): Promise<unknown>;
51+
/**
52+
* Deprecated: use `request` instead
53+
*/
54+
enable(): Promise<unknown>;
55+
/**
56+
* Submits an RPC request
57+
* @param method
58+
* @param params
59+
* @protected
60+
*/
61+
protected rawRequest(method: string, params?: any): Promise<unknown>;
62+
/**
63+
* Monitor information
64+
* @param type {string} Type of information
65+
* @param listener {Function} Event listener
66+
* @example
67+
* provider.on('connected', listener)
68+
*/
69+
on(type: string, listener: (...args: any[]) => void): void;
70+
}

0 commit comments

Comments
 (0)