antelopeql 3.0.0-rc.7 → 3.0.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/dist/antelopeql.d.ts +41 -17
- package/dist/antelopeql.js +117 -67
- package/dist/antelopeql.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/sha256.js +1 -0
- package/dist/utils/sha256.js.map +1 -1
- package/package.json +5 -4
- package/readme.md +42 -41
package/dist/antelopeql.d.ts
CHANGED
|
@@ -1,21 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type
|
|
3
|
-
|
|
4
|
-
export interface AntelopeQLArgument {
|
|
1
|
+
import { SignTransactionContext } from "antelopeql";
|
|
2
|
+
import { type GraphQLError, type GraphQLFieldConfig } from "graphql";
|
|
3
|
+
export interface AntelopeQLRequest {
|
|
5
4
|
query: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
contracts?: string[];
|
|
9
|
-
ABIs?: AccountABI[];
|
|
10
|
-
signTransaction?: SignTransactionContext;
|
|
11
|
-
rpc_url: string | URL | Request;
|
|
12
|
-
fetchOptions?: RequestInit;
|
|
13
|
-
}
|
|
14
|
-
export interface AntelopeQLResult {
|
|
15
|
-
data?: any;
|
|
16
|
-
errors?: Array<GraphQLError>;
|
|
5
|
+
operationName?: string | null;
|
|
6
|
+
variables?: Record<string, any> | null;
|
|
17
7
|
}
|
|
18
8
|
/**
|
|
19
|
-
*
|
|
9
|
+
* List of Antelope chains.
|
|
10
|
+
*/
|
|
11
|
+
declare type ChainsType = "vaulta" | "telos" | "xpr" | "wax" | "jungle" | string;
|
|
12
|
+
/**
|
|
13
|
+
* Lists you smart contracts across the various Antelope chains.
|
|
20
14
|
*/
|
|
21
|
-
export declare
|
|
15
|
+
export declare type ContractsType = {
|
|
16
|
+
[key in ChainsType]?: string[];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Enables you to enhance your GraphQL schema to add auxiliary queries and mnutation fields to your API.
|
|
20
|
+
*/
|
|
21
|
+
declare type ExtendQueryType = {
|
|
22
|
+
query?: {
|
|
23
|
+
[name in string]: GraphQLFieldConfig<unknown, unknown, unknown>;
|
|
24
|
+
};
|
|
25
|
+
mutation?: {
|
|
26
|
+
[name in string]: GraphQLFieldConfig<unknown, unknown, unknown>;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export declare type APIOptionsType = {
|
|
30
|
+
signTransaction?: SignTransactionContext;
|
|
31
|
+
contracts?: ContractsType;
|
|
32
|
+
chains?: {
|
|
33
|
+
[chain_name in ChainsType]: URL | string;
|
|
34
|
+
};
|
|
35
|
+
fetchOptions?: RequestInit;
|
|
36
|
+
abiFetchOptions?: RequestInit;
|
|
37
|
+
extendQuery?: ExtendQueryType;
|
|
38
|
+
};
|
|
39
|
+
export declare type AntelopeQLResult = {
|
|
40
|
+
data?: any;
|
|
41
|
+
errors?: ReadonlyArray<GraphQLError>;
|
|
42
|
+
};
|
|
43
|
+
export declare const default_rpc_urls: { [chain in ChainsType]: string | URL; };
|
|
44
|
+
export declare function AntelopeQL({ query, variables, operationName }: AntelopeQLRequest, options?: APIOptionsType): Promise<AntelopeQLResult>;
|
|
45
|
+
export {};
|
package/dist/antelopeql.js
CHANGED
|
@@ -1,77 +1,127 @@
|
|
|
1
|
+
import { blockchain_query_field, build_graphql_fields_from_abis, get_abis, send_serialized_transaction, send_transaction, serialize_transaction, actions_type as actions } from "antelopeql";
|
|
1
2
|
import { execute, GraphQLObjectType, GraphQLSchema, parse, Source, validate } from "graphql";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
const defaultChains = [
|
|
4
|
+
"vaulta",
|
|
5
|
+
"telos",
|
|
6
|
+
"xpr",
|
|
7
|
+
"wax",
|
|
8
|
+
"jungle"
|
|
9
|
+
];
|
|
10
|
+
export const default_rpc_urls = {
|
|
11
|
+
// Chain - aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906
|
|
12
|
+
vaulta: "https://eos.relocke.io",
|
|
13
|
+
// Chain - 4667b205c6838ef70ff7988f6e8257e8be0e1284a2f59699054a018f743b1d11
|
|
14
|
+
telos: "https://telos.relocke.io",
|
|
15
|
+
// chain - 384da888112027f0321850a169f737c33e53b388aad48b5adace4bab97f437e0
|
|
16
|
+
xpr: "https://proton.relocke.io",
|
|
17
|
+
// chain - 1064487b3cd1a897ce03ae5b6a865651747e2e152090f99c1d19d44e01aea5a4
|
|
18
|
+
wax: "https://wax.relocke.io",
|
|
19
|
+
// Chain - 73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d
|
|
20
|
+
jungle: "https://jungle.relocke.io"
|
|
21
|
+
};
|
|
22
|
+
export async function AntelopeQL({ query, variables, operationName }, options) {
|
|
23
|
+
const build_chains = new Set(defaultChains);
|
|
24
|
+
if (options?.chains)
|
|
25
|
+
Object.keys(options?.chains).forEach((chain) => build_chains.add(chain));
|
|
26
|
+
const chains = [...build_chains];
|
|
27
|
+
const fields = {};
|
|
28
|
+
const mutationFields = {};
|
|
29
|
+
for await (const chain of chains) {
|
|
30
|
+
const rpc_url = options?.chains?.[chain] ?? default_rpc_urls[chain];
|
|
31
|
+
const contracts = options?.contracts?.[chain] ?? [];
|
|
32
|
+
const typeResolution = chain.padStart(!chain.length ? 0 : chain.length + 1, "_");
|
|
33
|
+
const abis = (await get_abis(contracts, {
|
|
16
34
|
rpc_url,
|
|
17
|
-
fetchOptions
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (Object.keys(mutation_fields).length) {
|
|
29
|
-
const action_fields = actions(mutation_fields);
|
|
30
|
-
mutations = new GraphQLObjectType({
|
|
31
|
-
name: "Mutation",
|
|
35
|
+
fetchOptions: options?.abiFetchOptions
|
|
36
|
+
}));
|
|
37
|
+
const T = abis.map((x) => ({
|
|
38
|
+
account_name: x.account_name,
|
|
39
|
+
abi: x.abi
|
|
40
|
+
}));
|
|
41
|
+
const { mutation_fields, query_fields, ast_list } = build_graphql_fields_from_abis(T, typeResolution);
|
|
42
|
+
fields[chain] = {
|
|
43
|
+
type: new GraphQLObjectType({
|
|
44
|
+
description: `Query infomation about the ${chain} and smart contracts.`,
|
|
45
|
+
name: `${chain}_query`,
|
|
32
46
|
fields: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
send_serialized_transaction
|
|
47
|
+
get_blockchain: blockchain_query_field,
|
|
48
|
+
...query_fields
|
|
36
49
|
}
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
50
|
+
}),
|
|
51
|
+
resolve() {
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
mutationFields[chain] = {
|
|
56
|
+
resolve() {
|
|
57
|
+
return {};
|
|
58
|
+
},
|
|
59
|
+
type: new GraphQLObjectType({
|
|
60
|
+
description: `Serialise and update the smart contracts for ${chain}.`,
|
|
61
|
+
name: chain + "_mutation",
|
|
42
62
|
fields: {
|
|
43
|
-
send_serialized_transaction
|
|
63
|
+
send_serialized_transaction,
|
|
64
|
+
...(Object.keys(mutation_fields)?.length
|
|
65
|
+
? (() => {
|
|
66
|
+
const a = actions(mutation_fields, typeResolution);
|
|
67
|
+
const serialize_transaction_type = serialize_transaction(a, ast_list);
|
|
68
|
+
const map = {
|
|
69
|
+
serialize_transaction: serialize_transaction_type
|
|
70
|
+
};
|
|
71
|
+
if (options?.signTransaction) {
|
|
72
|
+
map.send_transaction = send_transaction(a, ast_list);
|
|
73
|
+
}
|
|
74
|
+
return map;
|
|
75
|
+
})()
|
|
76
|
+
: {})
|
|
44
77
|
}
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
78
|
+
})
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const extended_query = options?.extendQuery?.query ?? {};
|
|
82
|
+
const queries = new GraphQLObjectType({
|
|
83
|
+
name: "Query",
|
|
84
|
+
fields: {
|
|
85
|
+
...fields,
|
|
86
|
+
...extended_query
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
const extended_mutation = options?.extendQuery?.mutation ?? {};
|
|
90
|
+
const mutations = new GraphQLObjectType({
|
|
91
|
+
name: "Mutation",
|
|
92
|
+
fields: { ...mutationFields, ...extended_mutation }
|
|
93
|
+
});
|
|
94
|
+
const schema = new GraphQLSchema({ query: queries, mutation: mutations });
|
|
95
|
+
const document = parse(new Source(query));
|
|
96
|
+
const queryErrors = validate(schema, document);
|
|
97
|
+
if (queryErrors?.length)
|
|
98
|
+
return { errors: queryErrors };
|
|
99
|
+
const data = await execute({
|
|
100
|
+
schema,
|
|
101
|
+
document,
|
|
102
|
+
rootValue: {},
|
|
103
|
+
contextValue: {
|
|
104
|
+
network: (root, args, info) => {
|
|
105
|
+
const getFieldPath = (path, c) => !path.prev
|
|
106
|
+
? (c?.typename ?? "")
|
|
107
|
+
.replace(/_query$/gmu, "")
|
|
108
|
+
.replace(/_mutation$/gmu, "")
|
|
109
|
+
: getFieldPath(path.prev, path);
|
|
110
|
+
const chain = getFieldPath(info.path);
|
|
111
|
+
const rpc_url = options?.chains?.[chain] ?? default_rpc_urls[chain];
|
|
112
|
+
return { rpc_url, fetchOptions: options?.fetchOptions };
|
|
64
113
|
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return rootValue?.[fieldName];
|
|
114
|
+
async signTransaction(hash, serialized_transaction, transaction) {
|
|
115
|
+
if (options?.signTransaction)
|
|
116
|
+
return options?.signTransaction(hash, serialized_transaction, transaction);
|
|
69
117
|
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
118
|
+
},
|
|
119
|
+
variableValues: variables,
|
|
120
|
+
operationName,
|
|
121
|
+
async fieldResolver(rootValue, args, ctx, { fieldName }) {
|
|
122
|
+
return rootValue[fieldName];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return data;
|
|
76
126
|
}
|
|
77
127
|
//# sourceMappingURL=antelopeql.js.map
|
package/dist/antelopeql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"antelopeql.js","sourceRoot":"","sources":["../src/antelopeql.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,
|
|
1
|
+
{"version":3,"file":"antelopeql.js","sourceRoot":"","sources":["../src/antelopeql.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,8BAA8B,EAC9B,QAAQ,EACR,2BAA2B,EAC3B,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,IAAI,OAAO,EAKxB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,aAAa,EACb,KAAK,EACL,MAAM,EACN,QAAQ,EAMT,MAAM,SAAS,CAAC;AAoDjB,MAAM,aAAa,GAAG;IACpB,QAAQ;IACR,OAAO;IACP,KAAK;IACL,KAAK;IACL,QAAQ;CACO,CAAC;AAElB,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,2EAA2E;IAC3E,MAAM,EAAE,wBAAwB;IAChC,2EAA2E;IAC3E,KAAK,EAAE,0BAA0B;IACjC,2EAA2E;IAC3E,GAAG,EAAE,2BAA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,EAAE,EAAE,CAAC;oBACjC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAEpC,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAe,CAAC;gBACpD,MAAM,OAAO,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC;gBAEpE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;YAC1D,CAAC;YACD,KAAK,CAAC,eAAe,CAAC,IAAI,EAAE,sBAAsB,EAAE,WAAW;gBAC7D,IAAI,OAAO,EAAE,eAAe;oBAC1B,OAAO,OAAO,EAAE,eAAe,CAC7B,IAAI,EACJ,sBAAsB,EACtB,WAAW,CACZ,CAAC;YACN,CAAC;SACS;QACZ,cAAc,EAAE,SAAS;QACzB,aAAa;QACb,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE;YACrD,OAAO,SAAS,CAAC,SAAS,CAAC,CAAC;QAC9B,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AntelopeQL } from "./antelopeql.js";
|
|
1
|
+
export { AntelopeQL, default_rpc_urls, type AntelopeQLRequest, type APIOptionsType, type AntelopeQLResult, type ContractsType } from "./antelopeql.js";
|
|
2
2
|
export { serialize_transaction } from "./serialize_transaction.js";
|
|
3
3
|
export { serialize_abi } from "./serialize_abi.js";
|
|
4
4
|
export { send_transaction, type SerializedTransaction } from "./send_transaction.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AntelopeQL } from "./antelopeql.js";
|
|
1
|
+
export { AntelopeQL, default_rpc_urls } from "./antelopeql.js";
|
|
2
2
|
export { serialize_transaction } from "./serialize_transaction.js";
|
|
3
3
|
export { serialize_abi } from "./serialize_abi.js";
|
|
4
4
|
export { send_transaction } from "./send_transaction.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,gBAAgB,EAKjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,gBAAgB,EAEjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,oBAAoB,EAErB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAoB,MAAM,eAAe,CAAC;AAC3D,OAAO,EACL,8BAA8B,EAE/B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAC;AAC9F,OAAO,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AACzF,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAEzF,OAAO,EAAE,YAAY,E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6 +1,7 @@
|
|
|
1
1
|
export async function sha256(data) {
|
|
2
2
|
// Browser or Edge Runtime
|
|
3
3
|
if (typeof crypto !== "undefined" && crypto.subtle) {
|
|
4
|
+
// @ts-ignore - WebCrypto subtle.digest accepts Uint8Array at runtime; TS incorrectly rejects ArrayBufferLike
|
|
4
5
|
const digest = await crypto.subtle.digest("SHA-256", data);
|
|
5
6
|
return new Uint8Array(digest);
|
|
6
7
|
}
|
package/dist/utils/sha256.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sha256.js","sourceRoot":"","sources":["../../src/utils/sha256.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAgB;IAC3C,0BAA0B;IAC1B,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QACnD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"sha256.js","sourceRoot":"","sources":["../../src/utils/sha256.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAgB;IAC3C,0BAA0B;IAC1B,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QACnD,6GAA6G;QAC7G,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAE3D,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAED,mCAAmC;IACnC,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;QAC7D,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;QACnD,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;QACxD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;AACnE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antelopeql",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "A GraphQL implementation for interacting with Antelope based blockchains.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"eslint": "eslint .",
|
|
17
17
|
"prettier": "prettier -c .",
|
|
18
18
|
"prettier:readme": "prettier --write readme.md",
|
|
19
|
-
"server": "
|
|
19
|
+
"server": "node test/server.js",
|
|
20
20
|
"types": "tsc -p jsconfig.json",
|
|
21
21
|
"prepublishOnly": "npm run build && npm run test"
|
|
22
22
|
},
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
"main": "./dist/index.js",
|
|
29
29
|
"module": "./dist/index.js",
|
|
30
30
|
"types": "./dist/index.d.ts",
|
|
31
|
-
"files": [
|
|
31
|
+
"files": [
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
32
34
|
"exports": {
|
|
33
35
|
".": {
|
|
34
36
|
"import": "./dist/index.js",
|
|
@@ -65,7 +67,6 @@
|
|
|
65
67
|
"nodemon": "^3.0.1",
|
|
66
68
|
"prettier": "^2.8.4",
|
|
67
69
|
"snapshot-assertion": "^5.0.0",
|
|
68
|
-
"test-director": "^10.0.0",
|
|
69
70
|
"ts-node": "^10.9.2",
|
|
70
71
|
"tsx": "^4.20.3",
|
|
71
72
|
"typescript": "^5.8.3"
|
package/readme.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.org/package/antelopeql) [](https://github.com/pur3miish/antelopeql/blob/main/LICENSE)
|
|
6
6
|
|
|
7
|
-
AntelopeQL (_Antelope Query Language_)
|
|
7
|
+
AntelopeQL (_Antelope Query Language_).
|
|
8
8
|
|
|
9
9
|
AntelopeQL is a GraphQL client and server library that allows developers to interact with the Antelope blockchain using GraphQL. It provides a unified interface to communicate with different blockchains within the Antelope ecosystem, enabling developers to leverage the unique features and capabilities of each blockchain while still benefiting from a consistent development experience.
|
|
10
10
|
|
|
@@ -12,6 +12,8 @@ As a GraphQL client library, AntelopeQL simplifies the process of building and e
|
|
|
12
12
|
|
|
13
13
|
With AntelopeQL, developers can focus on building the frontend and business logic of their DApps, while relying on the library to handle the complexities of interacting with multiple blockchains in the Antelope ecosystem.
|
|
14
14
|
|
|
15
|
+
**Live working example can be found [here](https://relocke.io/api/playground).**
|
|
16
|
+
|
|
15
17
|

|
|
16
18
|
|
|
17
19
|
## Installation
|
|
@@ -26,77 +28,76 @@ npm install antelopeql graphql
|
|
|
26
28
|
|
|
27
29
|
See the examples folder on how to run AntelopeQL as a [Node.js](https://nodejs.org) endpoint.
|
|
28
30
|
|
|
29
|
-
### Query a
|
|
31
|
+
### Query a Blockchain Account Info
|
|
30
32
|
|
|
31
33
|
```js
|
|
32
34
|
import { AntelopeQL } from "antelopeql";
|
|
33
35
|
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const query = /* GraphQL */ `
|
|
37
|
+
{
|
|
38
|
+
vaulta {
|
|
39
|
+
get_blockchain {
|
|
40
|
+
get_account(account_name: "relockeblock") {
|
|
38
41
|
core_liquid_balance
|
|
39
42
|
ram_quota
|
|
40
43
|
net_weight
|
|
41
44
|
cpu_weight
|
|
42
45
|
ram_usage
|
|
43
|
-
permissions {
|
|
44
|
-
linked_actions {
|
|
45
|
-
account
|
|
46
|
-
action
|
|
47
|
-
}
|
|
48
|
-
required_auth {
|
|
49
|
-
keys {
|
|
50
|
-
key
|
|
51
|
-
weight
|
|
52
|
-
}
|
|
53
|
-
threshold
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
46
|
}
|
|
57
47
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
const { data } = await AntelopeQL({ query });
|
|
61
53
|
|
|
62
54
|
console.log(data);
|
|
63
55
|
```
|
|
64
56
|
|
|
65
57
|
> Logged output included an account infomation.
|
|
66
58
|
|
|
67
|
-
### Transfer
|
|
59
|
+
### Transfer Tokens
|
|
68
60
|
|
|
69
61
|
```js
|
|
70
62
|
import { AntelopeQL } from "antelopeql";
|
|
71
63
|
import sign_txn from "antelopeql-ecc/sign_txn.js";
|
|
72
64
|
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
send_transaction(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
65
|
+
const query = /* GraphQL */ `
|
|
66
|
+
mutation {
|
|
67
|
+
jungle {
|
|
68
|
+
send_transaction(
|
|
69
|
+
actions: [
|
|
70
|
+
{
|
|
71
|
+
eosio_token: {
|
|
72
|
+
transfer: {
|
|
73
|
+
authorization: { actor: "relockeblock" }
|
|
74
|
+
to: "relockechain"
|
|
75
|
+
from: "relockeblock"
|
|
76
|
+
memo: ""
|
|
77
|
+
quantity: "0.0002 EOS"
|
|
78
|
+
}
|
|
81
79
|
}
|
|
82
|
-
to:"relockechain"
|
|
83
|
-
from:"relockeblock"
|
|
84
|
-
memo: ""
|
|
85
|
-
quantity: "0.0002 EOS"
|
|
86
80
|
}
|
|
87
|
-
|
|
88
|
-
|
|
81
|
+
]
|
|
82
|
+
) {
|
|
89
83
|
transaction_id
|
|
90
84
|
block_num
|
|
91
85
|
}
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
|
|
90
|
+
const { data } = await AntelopeQL({
|
|
91
|
+
query,
|
|
92
|
+
contracts: {
|
|
93
|
+
// List of your smart contracts accounts for each chains.
|
|
94
|
+
jungle: ["eosio.token"]
|
|
95
|
+
},
|
|
94
96
|
signTransaction: async (hash) => {
|
|
95
97
|
const wif_private_key = "PVT_K1_…"; // your private key
|
|
96
98
|
const signature = await sign_txn({ hash, wif_private_key });
|
|
97
99
|
return [signature]; // signatures must return array
|
|
98
|
-
}
|
|
99
|
-
rpc_url: "https://eos.relocke.io" // eos blockchain url.
|
|
100
|
+
}
|
|
100
101
|
});
|
|
101
102
|
|
|
102
103
|
console.log(data);
|