@com-chain/jsc3l 2.0.1-rc.7 → 2.0.1-rc.8
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/build/bcTransaction.d.ts +2 -1
- package/build/bcTransaction.js +53 -75
- package/build/bcTransaction.js.map +1 -1
- package/build/config/transactions.d.ts +44 -0
- package/build/config/transactions.js +33 -0
- package/build/config/transactions.js.map +1 -0
- package/build/connection.js +14 -8
- package/build/connection.js.map +1 -1
- package/build/customization.js +11 -2
- package/build/customization.js.map +1 -1
- package/build/index.d.ts +6 -5
- package/build/index.js +22 -11
- package/build/index.js.map +1 -1
- package/build/qr.d.ts +31 -6
- package/build/qr.js +32 -12
- package/build/qr.js.map +1 -1
- package/build/rest/ajaxReq.d.ts +0 -2
- package/build/rest/ajaxReq.js +0 -6
- package/build/rest/ajaxReq.js.map +1 -1
- package/build/type.d.ts +4 -4
- package/build/wallet.d.ts +7 -8
- package/build/wallet.js +34 -36
- package/build/wallet.js.map +1 -1
- package/package.json +1 -1
- package/src/bcTransaction.ts +55 -76
- package/src/config/transactions.ts +34 -0
- package/src/connection.ts +15 -7
- package/src/customization.ts +17 -2
- package/src/index.ts +37 -13
- package/src/qr.ts +86 -12
- package/src/rest/ajaxReq.ts +0 -8
- package/src/wallet.ts +44 -47
package/build/qr.js
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import ethUtil from 'ethereumjs-util';
|
|
2
|
-
export function
|
|
3
|
-
let data, signature;
|
|
4
|
-
try {
|
|
5
|
-
({ data, signature } = JSON.parse(qrString));
|
|
6
|
-
}
|
|
7
|
-
catch (e) {
|
|
8
|
-
return 'InvalidFormat';
|
|
9
|
-
}
|
|
10
|
-
return checkSignedQR(data, signature, intendedRecipientAddress);
|
|
11
|
-
}
|
|
12
|
-
export function checkSignedQR(data, signature, intendedRecipientAddress) {
|
|
2
|
+
export function checkSignedQR(qrContent, intendedRecipientAddress) {
|
|
13
3
|
let hash;
|
|
14
4
|
let publicSignKey;
|
|
15
5
|
let receiverAddress;
|
|
6
|
+
const { data, signature } = qrContent;
|
|
16
7
|
try {
|
|
17
8
|
hash = ethUtil.sha3(JSON.stringify(data));
|
|
18
9
|
publicSignKey = ethUtil.ecrecover(hash, signature.v, signature.r, signature.s);
|
|
19
10
|
receiverAddress = ethUtil.bufferToHex(ethUtil.publicToAddress(publicSignKey));
|
|
20
11
|
}
|
|
21
12
|
catch (e) {
|
|
13
|
+
// XXXVlab: should probably use exceptions
|
|
22
14
|
return 'InvalidFormat';
|
|
23
15
|
}
|
|
24
16
|
if (receiverAddress !== data.address) {
|
|
@@ -30,6 +22,34 @@ export function checkSignedQR(data, signature, intendedRecipientAddress) {
|
|
|
30
22
|
if ((new Date(data.end)).getTime() < (new Date()).getTime()) {
|
|
31
23
|
return 'Expired';
|
|
32
24
|
}
|
|
33
|
-
return
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
export function makeSignedQRFragments(qrContent, fragmentCount) {
|
|
28
|
+
const signatureId = qrContent.signature.s.substring(4, 8);
|
|
29
|
+
const qrString = JSON.stringify(qrContent);
|
|
30
|
+
const fragmentSize = Math.ceil(qrString.length / fragmentCount);
|
|
31
|
+
const fragments = {
|
|
32
|
+
full: qrString,
|
|
33
|
+
};
|
|
34
|
+
for (let i = 0; i < fragmentCount; i++) {
|
|
35
|
+
fragments[i] = `FRAG_CR${signatureId}${i}${qrString.substring(fragmentSize * i, Math.min(fragmentSize * (i + 1), qrString.length))}`;
|
|
36
|
+
}
|
|
37
|
+
return fragments;
|
|
38
|
+
}
|
|
39
|
+
export function makeSignedQRContent(obj, privKey) {
|
|
40
|
+
const { begin, end } = obj;
|
|
41
|
+
const formatDate = (date) => `${date.getFullYear()}/${date.getMonth()}/${date.getDate()}`;
|
|
42
|
+
const data = Object.assign(obj, {
|
|
43
|
+
begin: formatDate(begin),
|
|
44
|
+
end: formatDate(end),
|
|
45
|
+
});
|
|
46
|
+
const hash = ethUtil.sha3(JSON.stringify(data));
|
|
47
|
+
const { v, r, s } = ethUtil.ecsign(hash, privKey);
|
|
48
|
+
const signature = {
|
|
49
|
+
v,
|
|
50
|
+
r: '0x' + r.toString('hex'),
|
|
51
|
+
s: '0x' + s.toString('hex'),
|
|
52
|
+
};
|
|
53
|
+
return { data, signature };
|
|
34
54
|
}
|
|
35
55
|
//# sourceMappingURL=qr.js.map
|
package/build/qr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qr.js","sourceRoot":"","sources":["../src/qr.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"qr.js","sourceRoot":"","sources":["../src/qr.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,iBAAiB,CAAA;AAkCrC,MAAM,UAAU,aAAa,CAAE,SAAmB,EAAE,wBAAwB;IAE1E,IAAI,IAAY,CAAA;IAChB,IAAI,aAAqB,CAAA;IACzB,IAAI,eAAuB,CAAA;IAC3B,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,SAAS,CAAA;IACrC,IAAI;QACF,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;QACzC,aAAa,GAAG,OAAO,CAAC,SAAS,CAC/B,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAA;QAC9C,eAAe,GAAG,OAAO,CAAC,WAAW,CACnC,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CAAA;KAC1C;IAAC,OAAO,CAAC,EAAE;QACV,0CAA0C;QAC1C,OAAO,eAAe,CAAA;KACvB;IAED,IAAI,eAAe,KAAK,IAAI,CAAC,OAAO,EAAE;QACpC,OAAO,kBAAkB,CAAA;KAC1B;IACD,IAAI,IAAI,CAAC,SAAS,KAAK,wBAAwB,EAAE;QAC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AE,CAAA;IAC9D,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE;QAC9B,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC;QACxB,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC;KACrB,CAAC,CAAA;IAEF,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;IAC/C,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IACjD,MAAM,SAAS,GAAG;QAChB,CAAC;QACD,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC3B,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;KAC5B,CAAA;IAED,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;AAE5B,CAAC"}
|
package/build/rest/ajaxReq.d.ts
CHANGED
|
@@ -13,8 +13,6 @@ export default abstract class AjaxReqAbstract {
|
|
|
13
13
|
getEthCall(txobj: any): Promise<unknown>;
|
|
14
14
|
getEthCallAt(txobj: any, blockNb: any): Promise<unknown>;
|
|
15
15
|
enrollPost(data: any): any;
|
|
16
|
-
validateEnrollmentLetter(id: any, currency: any, signature: any): any;
|
|
17
|
-
enrollAddress(id: any, address: any, currency: any, token: any): any;
|
|
18
16
|
getTransList(id: any, count: any, offset: any): Promise<any>;
|
|
19
17
|
getTransCheck(hash: any): any;
|
|
20
18
|
getExportTransList(id: any, start: any, end: any): Promise<any>;
|
package/build/rest/ajaxReq.js
CHANGED
|
@@ -63,12 +63,6 @@ export default class AjaxReqAbstract {
|
|
|
63
63
|
enrollPost(data) {
|
|
64
64
|
return this.endpoint.post(URL.ENROLL, { data: JSON.stringify(data) });
|
|
65
65
|
}
|
|
66
|
-
validateEnrollmentLetter(id, currency, signature) {
|
|
67
|
-
return this.enrollPost({ id, currency, signature });
|
|
68
|
-
}
|
|
69
|
-
enrollAddress(id, address, currency, token) {
|
|
70
|
-
return this.enrollPost({ id, addresse: address, token, currency });
|
|
71
|
-
}
|
|
72
66
|
async getTransList(id, count, offset) {
|
|
73
67
|
// for some strange reasons, the answer is stringified 2 times,
|
|
74
68
|
// so we need to unpack each entry a second time.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ajaxReq.js","sourceRoot":"","sources":["../../src/rest/ajaxReq.ts"],"names":[],"mappings":"AACA,MAAM,GAAG;;AACA,UAAM,GAAG,SAAS,CAAC;AACnB,UAAM,GAAG,YAAY,CAAC;AACtB,YAAQ,GAAG,cAAc,CAAC;AAC1B,aAAS,GAAG,SAAS,CAAC;AACtB,cAAU,GAAG,YAAY,CAAC;AAC1B,WAAO,GAAG,YAAY,CAAC;AACvB,cAAU,GAAG,YAAY,CAAC;AAC1B,YAAQ,GAAG,UAAU,CAAC;AACtB,mBAAe,GAAG,qBAAqB,CAAC;AAIjD,MAAM,CAAC,OAAO,OAAgB,eAAe;IAA7C;QAME,iBAAY,GAAG,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"ajaxReq.js","sourceRoot":"","sources":["../../src/rest/ajaxReq.ts"],"names":[],"mappings":"AACA,MAAM,GAAG;;AACA,UAAM,GAAG,SAAS,CAAC;AACnB,UAAM,GAAG,YAAY,CAAC;AACtB,YAAQ,GAAG,cAAc,CAAC;AAC1B,aAAS,GAAG,SAAS,CAAC;AACtB,cAAU,GAAG,YAAY,CAAC;AAC1B,WAAO,GAAG,YAAY,CAAC;AACvB,cAAU,GAAG,YAAY,CAAC;AAC1B,YAAQ,GAAG,UAAU,CAAC;AACtB,mBAAe,GAAG,qBAAqB,CAAC;AAIjD,MAAM,CAAC,OAAO,OAAgB,eAAe;IAA7C;QAME,iBAAY,GAAG,EAAE,CAAA;IAkInB,CAAC;IAhIC,EAAE;IACF,6DAA6D;IAC7D,EA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CAAC;CAEF"}
|
package/build/type.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const httpMethods: readonly ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD"];
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type httpMethod = typeof httpMethods[number];
|
|
3
|
+
export type coreHttpOpts = {
|
|
4
4
|
protocol: string;
|
|
5
5
|
host: string;
|
|
6
6
|
path: string;
|
|
@@ -10,13 +10,13 @@ export declare type coreHttpOpts = {
|
|
|
10
10
|
data?: any;
|
|
11
11
|
timeout?: number;
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export type HttpRequest = (opts: coreHttpOpts) => Object;
|
|
14
14
|
export interface IPersistentStore {
|
|
15
15
|
get(key: string, defaultValue?: string): string;
|
|
16
16
|
set(key: string, value: string): void;
|
|
17
17
|
del(key: string): void;
|
|
18
18
|
}
|
|
19
|
-
export
|
|
19
|
+
export type UrlParts = {
|
|
20
20
|
protocol: string;
|
|
21
21
|
host: string;
|
|
22
22
|
port: number;
|
package/build/wallet.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import AjaxReq from './rest/ajaxReq';
|
|
2
|
+
import { SignedQR } from './qr';
|
|
2
3
|
import Wallet from './ethereum/myetherwallet';
|
|
3
4
|
export default abstract class MessagingWalletAbstract extends Wallet {
|
|
4
5
|
abstract ajaxReq: AjaxReq;
|
|
@@ -21,15 +22,13 @@ export default abstract class MessagingWalletAbstract extends Wallet {
|
|
|
21
22
|
encryptWallet(password: any): {
|
|
22
23
|
[k: string]: any;
|
|
23
24
|
};
|
|
24
|
-
|
|
25
|
+
validateEnrollment(id: any, signature: any): any;
|
|
26
|
+
enrollAddress(id: any, token: any): any;
|
|
25
27
|
requestUnlock(): any;
|
|
26
28
|
static getWalletFromPrivKeyFile(jsonStr: any, password: any): Wallet;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
makeSignedQR(obj: any): {
|
|
32
|
-
signature: any;
|
|
33
|
-
qrContent: string;
|
|
29
|
+
makeSignedQRContent(obj: any, pubKey: string | null): SignedQR;
|
|
30
|
+
makeSignedQRFragments(obj: any, fragmentCount: number, pubKey: string | null): {
|
|
31
|
+
full: string;
|
|
34
32
|
};
|
|
33
|
+
checkSignedQRFromString(qrString: string): true | "InvalidFormat" | "InvalidSignature" | "NotForYou" | "Expired";
|
|
35
34
|
}
|
package/build/wallet.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { checkSignedQR, makeSignedQRContent, makeSignedQRFragments } from './qr';
|
|
2
2
|
import { shortenAddress, cipherMsg, decipherMsg } from './ethereum/cipher';
|
|
3
3
|
import Wallet from './ethereum/myetherwallet';
|
|
4
4
|
export default class MessagingWalletAbstract extends Wallet {
|
|
@@ -99,8 +99,21 @@ export default class MessagingWalletAbstract extends Wallet {
|
|
|
99
99
|
message_key: this.message_key
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
return this.ajaxReq.
|
|
102
|
+
validateEnrollment(id, signature) {
|
|
103
|
+
return this.ajaxReq.enrollPost({
|
|
104
|
+
id,
|
|
105
|
+
signature,
|
|
106
|
+
currency: this.currencyName,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
enrollAddress(id, token) {
|
|
110
|
+
return this.ajaxReq.enrollPost({
|
|
111
|
+
id,
|
|
112
|
+
token,
|
|
113
|
+
currency: this.currencyName,
|
|
114
|
+
// XXXvlab: Yes, typo is intentional here (in PHP API):
|
|
115
|
+
addresse: this.getAddressString(),
|
|
116
|
+
});
|
|
104
117
|
}
|
|
105
118
|
requestUnlock() {
|
|
106
119
|
return this.ajaxReq.requestUnlock(this.getAddressString(), this.unlockUrl);
|
|
@@ -124,40 +137,25 @@ export default class MessagingWalletAbstract extends Wallet {
|
|
|
124
137
|
}
|
|
125
138
|
}
|
|
126
139
|
//
|
|
127
|
-
// QR
|
|
140
|
+
// QR Code helpers
|
|
128
141
|
//
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return
|
|
146
|
-
signature,
|
|
147
|
-
qrContent: JSON.stringify({
|
|
148
|
-
data: objContent,
|
|
149
|
-
signature: {
|
|
150
|
-
v: signature.v,
|
|
151
|
-
r: '0x' + signature.r.toString('hex'),
|
|
152
|
-
s: '0x' + signature.s.toString('hex')
|
|
153
|
-
}
|
|
154
|
-
})
|
|
155
|
-
};
|
|
142
|
+
makeSignedQRContent(obj, pubKey) {
|
|
143
|
+
return makeSignedQRContent(Object.assign(Object.assign({ server: this.currencyName, address: this.getAddressString() }, obj), pubKey && {
|
|
144
|
+
message_key: cipherMsg(pubKey, this.messageKeysFromWallet())
|
|
145
|
+
}), this.privKey);
|
|
146
|
+
}
|
|
147
|
+
makeSignedQRFragments(obj, fragmentCount, pubKey) {
|
|
148
|
+
return makeSignedQRFragments(this.makeSignedQRContent(obj, pubKey), fragmentCount);
|
|
149
|
+
}
|
|
150
|
+
checkSignedQRFromString(qrString) {
|
|
151
|
+
let qrContent;
|
|
152
|
+
try {
|
|
153
|
+
qrContent = JSON.parse(qrString);
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
return 'InvalidFormat';
|
|
157
|
+
}
|
|
158
|
+
return checkSignedQR(qrContent, this.getAddressString());
|
|
156
159
|
}
|
|
157
160
|
}
|
|
158
|
-
// // TODO: What to do with this validateEnrollment
|
|
159
|
-
// public static validateEnrollment (codeId, signature) {
|
|
160
|
-
// return this.ajaxReq.validateEnrollmentLetter(
|
|
161
|
-
// codeId, this.currencyName, signature)
|
|
162
|
-
// }
|
|
163
161
|
//# sourceMappingURL=wallet.js.map
|
package/build/wallet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAAY,mBAAmB,EAAE,qBAAqB,EACpE,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC1E,OAAO,MAAM,MAAM,0BAA0B,CAAA;AAG7C,MAAM,CAAC,OAAO,OAAgB,uBAAwB,SAAQ,MAAM;IAApE;;QAME,gBAAW,GAAuC,IAAI,CAAA;IAuLxD,CAAC;IArLQ,MAAM,CAAC,KAAK,CAAC,YAAY;QAC9B,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAA;QACzB,MAAM,MAAM,CAAC,sBAAsB,EAAE,CAAA;QACrC,OAAO,MAAM,CAAA;IACf,CAAC;IAEO,iBAAiB;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC;YAC7B,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE;YAChC,kBAAkB,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG;YACxC,mBAAmB,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;SAC3C,CAAC,CAAA;QAEF,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAA;IAC3E,CAAC;IAEM,KAAK,CAAC,kBAAkB,CAAE,KAAK,EAAE,OAAO;QAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAA;QACvC,MAAM,MAAM,GAAG,KAAK,EAAE,GAAG,EAAE,EAAE,CAC3B,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,EAAE,KAAK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AAuB,CAAE,QAAgB;QAC9C,IAAI,SAAmB,CAAA;QACvB,IAAI;YACF,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;SACjC;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,eAAe,CAAA;SACvB;QACD,OAAO,aAAa,CAAC,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAA;IAC1D,CAAC;CAEF"}
|
package/package.json
CHANGED
package/src/bcTransaction.ts
CHANGED
|
@@ -16,9 +16,12 @@ function typeConv (label: string): (x:any) => (string | number) {
|
|
|
16
16
|
if (label.startsWith('limit') || label === 'amount') {
|
|
17
17
|
return (nb) => encodeNumber(roundCent(nb))
|
|
18
18
|
}
|
|
19
|
-
if (label.endsWith('Status') || label.endsWith('Type')) {
|
|
19
|
+
if (label.endsWith('Status') || label.endsWith('Type') || label.endsWith('Int')) {
|
|
20
20
|
return (nb) => encodeNumber(nb)
|
|
21
21
|
}
|
|
22
|
+
if (label.endsWith('Hex')) {
|
|
23
|
+
return (s) => s.padEnd(128, '0')
|
|
24
|
+
}
|
|
22
25
|
if (label === 'status') {
|
|
23
26
|
return (nb) => (parseInt(nb, 10) === 0 ? 0 : 1)
|
|
24
27
|
}
|
|
@@ -26,7 +29,7 @@ function typeConv (label: string): (x:any) => (string | number) {
|
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
|
|
29
|
-
export
|
|
32
|
+
export abstract class BcTransactionAbstract {
|
|
30
33
|
|
|
31
34
|
abstract ajaxReq: AjaxReq
|
|
32
35
|
abstract contracts: string[]
|
|
@@ -77,81 +80,57 @@ export default abstract class BcTransactionAbstract {
|
|
|
77
80
|
}
|
|
78
81
|
|
|
79
82
|
|
|
80
|
-
[
|
|
81
|
-
|
|
82
|
-
{
|
|
83
|
-
setAccountParam: '848b2592:accAddress accStatus accType limitPlus limitMinus',
|
|
84
|
-
pledgeAccount: '6c343eef:accAddress amount *',
|
|
85
|
-
setAllowance: 'd4e12f2e:spenderAddress amount',
|
|
86
|
-
setDelegation: '75741c79:spenderAddress limit',
|
|
87
|
-
setTaxAmount: 'f6f1897d:amount',
|
|
88
|
-
setTaxLegAmount: 'fafaf4c0:amount',
|
|
89
|
-
setTaxAccount: 'd0385b5e:accAddress',
|
|
90
|
-
setOwnerAccount: 'f2fde38b:accAddress',
|
|
91
|
-
setContractStatus: '0x88b8084f:status',
|
|
92
|
-
},
|
|
93
|
-
// Second Contract
|
|
94
|
-
{
|
|
95
|
-
transferNant: 'a5f7c148:toAddress amount *',
|
|
96
|
-
transferCM: '60ca9c4c:toAddress amount *',
|
|
97
|
-
transferOnBehalfNant: '1b6b1ee5:fromAddress toAddress amount D',
|
|
98
|
-
transferOnBehalfCM: '74c421fe:fromAddress toAddress amount D',
|
|
99
|
-
askTransferFrom: '58258353:fromAddress amount',
|
|
100
|
-
askTransferCMFrom: '2ef9ade2:fromAddress amount',
|
|
101
|
-
payRequestNant: '132019f4:toAddress amount *',
|
|
102
|
-
payRequestCM: '1415707c:toAddress amount *',
|
|
103
|
-
rejectRequest: 'af98f757:toAddress',
|
|
104
|
-
dismissAcceptedInfo: 'ccf93c7a:accAddress',
|
|
105
|
-
dismissRejectedInfo: '88759215:accAddress',
|
|
106
|
-
}
|
|
107
|
-
].forEach((contractFnDefs, contractNb) => {
|
|
108
|
-
|
|
109
|
-
for (const fnName in contractFnDefs) {
|
|
110
|
-
|
|
111
|
-
const [fnHash, argStringList] = contractFnDefs[fnName].split(':')
|
|
112
|
-
const argList = argStringList.split(' ')
|
|
113
|
-
let hasAdditionalPostData = false
|
|
114
|
-
let hasDelegate = false
|
|
115
|
-
if (argList.slice(-1)[0] === '*') {
|
|
116
|
-
hasAdditionalPostData = true
|
|
117
|
-
argList.pop()
|
|
118
|
-
} else if (argList.slice(-1)[0] === 'D') {
|
|
119
|
-
hasAdditionalPostData = true
|
|
120
|
-
hasDelegate = true
|
|
121
|
-
argList.pop()
|
|
122
|
-
}
|
|
83
|
+
export function transactionFactory(transactionDefs: any[], bcTransactionClass: any) {
|
|
84
|
+
|
|
85
|
+
transactionDefs.forEach((contractFnDefs, contractNb) => {
|
|
123
86
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
|
|
87
|
+
for (const fnName in contractFnDefs) {
|
|
88
|
+
|
|
89
|
+
const [fnHash, argStringList] = contractFnDefs[fnName].split(':')
|
|
90
|
+
const argList = argStringList.split(' ')
|
|
91
|
+
let hasAdditionalPostData = false
|
|
92
|
+
let hasDelegate = false
|
|
93
|
+
if (argList.slice(-1)[0] === '*') {
|
|
94
|
+
hasAdditionalPostData = true
|
|
95
|
+
argList.pop()
|
|
96
|
+
} else if (argList.slice(-1)[0] === 'D') {
|
|
97
|
+
hasAdditionalPostData = true
|
|
98
|
+
hasDelegate = true
|
|
99
|
+
argList.pop()
|
|
136
100
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
101
|
+
|
|
102
|
+
// Build argument array function
|
|
103
|
+
const argFnList = argList.map((arg) => typeConv(arg))
|
|
104
|
+
const concatArgs = (args) =>
|
|
105
|
+
args.map((arg, idx) => argFnList[idx](arg)).join('')
|
|
106
|
+
|
|
107
|
+
bcTransactionClass.prototype[fnName] = async function (wallet, ...args) {
|
|
108
|
+
const addr = wallet.getAddressString()
|
|
109
|
+
const data = await this.ajaxReq.getTransactionData(addr)
|
|
110
|
+
// TODO: must test this
|
|
111
|
+
if (data.error) {
|
|
112
|
+
console.log(`Failed getTransactionData(${addr})`)
|
|
113
|
+
throw new Error(data.msg)
|
|
114
|
+
}
|
|
115
|
+
const additionalPostData = hasAdditionalPostData ? args.pop() : {}
|
|
116
|
+
if (hasDelegate) {
|
|
117
|
+
additionalPostData.delegate = wallet.getAddressString()
|
|
118
|
+
}
|
|
119
|
+
const rawTx = generateTx({
|
|
120
|
+
gasLimit: 500000,
|
|
121
|
+
data: fnHash + concatArgs(args),
|
|
122
|
+
to: this.contracts[contractNb],
|
|
123
|
+
unit: 'ether',
|
|
124
|
+
value: 0,
|
|
125
|
+
nonce: 1,
|
|
126
|
+
gasPrice: null,
|
|
127
|
+
donate: false,
|
|
128
|
+
from: addr,
|
|
129
|
+
key: wallet.getPrivateKeyString()
|
|
130
|
+
}, data)
|
|
131
|
+
if (rawTx.isError) return rawTx
|
|
132
|
+
return this.ajaxReq.sendTx(rawTx.signedTx, additionalPostData)
|
|
140
133
|
}
|
|
141
|
-
const rawTx = generateTx({
|
|
142
|
-
gasLimit: 500000,
|
|
143
|
-
data: fnHash + concatArgs(args),
|
|
144
|
-
to: this.contracts[contractNb],
|
|
145
|
-
unit: 'ether',
|
|
146
|
-
value: 0,
|
|
147
|
-
nonce: 1,
|
|
148
|
-
gasPrice: null,
|
|
149
|
-
donate: false,
|
|
150
|
-
from: addr,
|
|
151
|
-
key: wallet.getPrivateKeyString()
|
|
152
|
-
}, data)
|
|
153
|
-
if (rawTx.isError) return rawTx
|
|
154
|
-
return this.ajaxReq.sendTx(rawTx.signedTx, additionalPostData)
|
|
155
134
|
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
135
|
+
})
|
|
136
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
export default [
|
|
4
|
+
// First Contract
|
|
5
|
+
{
|
|
6
|
+
setAccountParam: '848b2592:accAddress accStatus accType limitPlus limitMinus',
|
|
7
|
+
pledgeAccount: '6c343eef:accAddress amount *',
|
|
8
|
+
setAllowance: 'd4e12f2e:spenderAddress amount',
|
|
9
|
+
setDelegation: '75741c79:spenderAddress limit',
|
|
10
|
+
setTaxAmount: 'f6f1897d:amount',
|
|
11
|
+
setTaxLegAmount: 'fafaf4c0:amount',
|
|
12
|
+
setTaxAccount: 'd0385b5e:accAddress',
|
|
13
|
+
setOwnerAccount: 'f2fde38b:accAddress',
|
|
14
|
+
setContractStatus: '88b8084f:status',
|
|
15
|
+
},
|
|
16
|
+
// Second Contract
|
|
17
|
+
{
|
|
18
|
+
transferNant: 'a5f7c148:toAddress amount *',
|
|
19
|
+
transferCM: '60ca9c4c:toAddress amount *',
|
|
20
|
+
transferOnBehalfNant: '1b6b1ee5:fromAddress toAddress amount D',
|
|
21
|
+
transferOnBehalfCM: '74c421fe:fromAddress toAddress amount D',
|
|
22
|
+
askTransferFrom: '58258353:fromAddress amount',
|
|
23
|
+
askTransferCMFrom: '2ef9ade2:fromAddress amount',
|
|
24
|
+
payRequestNant: '132019f4:toAddress amount *',
|
|
25
|
+
payRequestCM: '1415707c:toAddress amount *',
|
|
26
|
+
rejectRequest: 'af98f757:toAddress',
|
|
27
|
+
dismissAcceptedInfo: 'ccf93c7a:accAddress',
|
|
28
|
+
dismissRejectedInfo: '88759215:accAddress',
|
|
29
|
+
},
|
|
30
|
+
// // Third Contract
|
|
31
|
+
// {
|
|
32
|
+
// replaceAccount: '3e3fc7c7:newAddress',
|
|
33
|
+
// }
|
|
34
|
+
]
|
package/src/connection.ts
CHANGED
|
@@ -43,8 +43,15 @@ abstract class ConnectionAbstract {
|
|
|
43
43
|
///
|
|
44
44
|
// [Lower level] Get the list of ComChain end-points from given repo
|
|
45
45
|
///
|
|
46
|
-
getCCEndPointList (repo: string) {
|
|
47
|
-
|
|
46
|
+
async getCCEndPointList (repo: string) {
|
|
47
|
+
try {
|
|
48
|
+
return await this.http.get(
|
|
49
|
+
repo + config.nodesRepo,
|
|
50
|
+
{ _: new Date().getTime() })
|
|
51
|
+
} catch (e) {
|
|
52
|
+
console.error(`Failed to get endpoint list on ${repo}`, e)
|
|
53
|
+
return false
|
|
54
|
+
}
|
|
48
55
|
}
|
|
49
56
|
|
|
50
57
|
///
|
|
@@ -232,11 +239,12 @@ export default abstract class ConnectionMgrAbstract extends ConnectionAbstract {
|
|
|
232
239
|
public getLocalConfJSON () {
|
|
233
240
|
if (this.conf) return this.conf
|
|
234
241
|
const cfgJson = this.persistentStore.get('ServerConf')
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
242
|
+
const cfg = cfgJson ? JSON.parse(cfgJson) : {}
|
|
243
|
+
// Completing with other informations if available
|
|
244
|
+
if (this.repo) {
|
|
245
|
+
cfg.repo = this.repo
|
|
246
|
+
cfg.custoRepo = this.repo + config.custoRepo
|
|
247
|
+
}
|
|
240
248
|
return cfg
|
|
241
249
|
}
|
|
242
250
|
|
package/src/customization.ts
CHANGED
|
@@ -131,14 +131,25 @@ export default abstract class CustomizationAbstract {
|
|
|
131
131
|
if (!currencyName) {
|
|
132
132
|
currencyName = this.cfg.server.name
|
|
133
133
|
}
|
|
134
|
+
if (!this.cfg.custoRepo) {
|
|
135
|
+
throw Error(
|
|
136
|
+
'Requested getCurrencyAssetBaseUrl while configuration is not available (yet?)'
|
|
137
|
+
)
|
|
138
|
+
}
|
|
134
139
|
return `${this.cfg.custoRepo}${currencyName}`
|
|
135
140
|
}
|
|
136
141
|
|
|
137
142
|
public getCssUrl (currencyName?: string) {
|
|
138
143
|
try {
|
|
139
|
-
// XXXvlab: I guess that we don't need to keep 'etherwallet' css
|
|
140
|
-
|
|
144
|
+
// XXXvlab: I guess that we don't need to keep 'etherwallet' css
|
|
145
|
+
// names
|
|
146
|
+
return this.getCurrencyAssetBaseUrl(currencyName) +
|
|
147
|
+
'/css/etherwallet-master.min.css'
|
|
141
148
|
} catch (e) {
|
|
149
|
+
console.log(
|
|
150
|
+
'`customization.getCssUrl(..)` called before configuration was ' +
|
|
151
|
+
"ready. Returning `localDefaultConf`'s value."
|
|
152
|
+
)
|
|
142
153
|
return this.localDefaultConf.server.url_Css
|
|
143
154
|
}
|
|
144
155
|
}
|
|
@@ -149,6 +160,10 @@ export default abstract class CustomizationAbstract {
|
|
|
149
160
|
// be agnostic ?
|
|
150
161
|
return `${this.getCurrencyAssetBaseUrl(currencyName)}/images/lem.png`
|
|
151
162
|
} catch (e) {
|
|
163
|
+
console.log(
|
|
164
|
+
'`customization.getCurrencyLogoUrl(..)` called before configuration ' +
|
|
165
|
+
'was ready. Returning empty string.'
|
|
166
|
+
)
|
|
152
167
|
return ''
|
|
153
168
|
}
|
|
154
169
|
}
|