@rango-dev/signer-tron 0.27.1-next.1 → 0.28.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/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var o=Object.defineProperty;var n=(a,r)=>o(a,"name",{value:r,configurable:!0});import{SignerError as t,SignerErrorCode as d}from"rango-types";var i=class a{static{n(this,"DefaultTronSigner")}constructor(r){this.provider=r}async signMessage(){throw t.UnimplementedError("signMessage")}async signAndSendTx(r){try{let e=a.buildTx(r),s=await this.provider.tronWeb.trx.sign(e);return{hash:(await this.provider.tronWeb.trx.sendRawTransaction(s))?.transaction?.txID}}catch(e){throw new t(d.SEND_TX_ERROR,void 0,e)}}static buildTx(r){let e={};return r.txID&&(e={...e,txID:r.txID}),r.visible!==void 0&&(e={...e,visible:r.visible}),r.__payload__&&(e={...e,__payload__:r.__payload__}),r.raw_data&&(e={...e,raw_data:r.raw_data}),r.raw_data_hex&&(e={...e,raw_data_hex:r.raw_data_hex}),e}};export{i as DefaultTronSigner};
1
+ var d=Object.defineProperty;var t=(a,r)=>d(a,"name",{value:r,configurable:!0});import{SignerError as n,SignerErrorCode as s}from"rango-types";var i=class a{static{t(this,"DefaultTronSigner")}constructor(r){this.provider=r}static buildTx(r){let e={};return r.txID&&(e={...e,txID:r.txID}),r.visible!==void 0&&(e={...e,visible:r.visible}),r.__payload__&&(e={...e,__payload__:r.__payload__}),r.raw_data&&(e={...e,raw_data:r.raw_data}),r.raw_data_hex&&(e={...e,raw_data_hex:r.raw_data_hex}),e}async signMessage(r){try{return await this.provider.tronWeb.trx.signMessageV2(r)}catch(e){throw new n(s.SIGN_TX_ERROR,void 0,e)}}async signAndSendTx(r){try{let e=a.buildTx(r),o=await this.provider.tronWeb.trx.sign(e);return{hash:(await this.provider.tronWeb.trx.sendRawTransaction(o))?.transaction?.txID}}catch(e){throw new n(s.SEND_TX_ERROR,void 0,e)}}};export{i as DefaultTronSigner};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/signer.ts"],
4
- "sourcesContent": ["import type { GenericSigner, TronTransaction } from 'rango-types';\n\nimport { SignerError, SignerErrorCode } from 'rango-types';\n\n// TODO - replace with real type\n// tslint:disable-next-line: no-any\ntype TronExternalProvider = any;\n\nexport class DefaultTronSigner implements GenericSigner<TronTransaction> {\n private provider: TronExternalProvider;\n\n constructor(provider: TronExternalProvider) {\n this.provider = provider;\n }\n\n async signMessage(): Promise<string> {\n throw SignerError.UnimplementedError('signMessage');\n }\n\n async signAndSendTx(tx: TronTransaction): Promise<{ hash: string }> {\n try {\n const transaction = DefaultTronSigner.buildTx(tx);\n const signedTxn = await this.provider.tronWeb.trx.sign(transaction);\n const receipt = await this.provider.tronWeb.trx.sendRawTransaction(\n signedTxn\n );\n const hash = receipt?.transaction?.txID;\n return { hash };\n } catch (error) {\n throw new SignerError(SignerErrorCode.SEND_TX_ERROR, undefined, error);\n }\n }\n\n static buildTx(tronTx: TronTransaction) {\n let tx = {};\n if (!!tronTx.txID) tx = { ...tx, txID: tronTx.txID };\n if (tronTx.visible !== undefined) tx = { ...tx, visible: tronTx.visible };\n if (!!tronTx.__payload__) tx = { ...tx, __payload__: tronTx.__payload__ };\n if (!!tronTx.raw_data) tx = { ...tx, raw_data: tronTx.raw_data };\n if (!!tronTx.raw_data_hex)\n tx = { ...tx, raw_data_hex: tronTx.raw_data_hex };\n return tx;\n }\n}\n"],
5
- "mappings": "+EAEA,OAAS,eAAAA,EAAa,mBAAAC,MAAuB,cAMtC,IAAMC,EAAN,MAAMC,CAA4D,CARzE,MAQyE,CAAAC,EAAA,0BAGvE,YAAYC,EAAgC,CAC1C,KAAK,SAAWA,CAClB,CAEA,MAAM,aAA+B,CACnC,MAAMC,EAAY,mBAAmB,aAAa,CACpD,CAEA,MAAM,cAAcC,EAAgD,CAClE,GAAI,CACF,IAAMC,EAAcL,EAAkB,QAAQI,CAAE,EAC1CE,EAAY,MAAM,KAAK,SAAS,QAAQ,IAAI,KAAKD,CAAW,EAKlE,MAAO,CAAE,MAJO,MAAM,KAAK,SAAS,QAAQ,IAAI,mBAC9CC,CACF,IACsB,aAAa,IACrB,CAChB,OAASC,EAAO,CACd,MAAM,IAAIJ,EAAYK,EAAgB,cAAe,OAAWD,CAAK,CACvE,CACF,CAEA,OAAO,QAAQE,EAAyB,CACtC,IAAIL,EAAK,CAAC,EACV,OAAMK,EAAO,OAAML,EAAK,CAAE,GAAGA,EAAI,KAAMK,EAAO,IAAK,GAC/CA,EAAO,UAAY,SAAWL,EAAK,CAAE,GAAGA,EAAI,QAASK,EAAO,OAAQ,GAClEA,EAAO,cAAaL,EAAK,CAAE,GAAGA,EAAI,YAAaK,EAAO,WAAY,GAClEA,EAAO,WAAUL,EAAK,CAAE,GAAGA,EAAI,SAAUK,EAAO,QAAS,GACzDA,EAAO,eACXL,EAAK,CAAE,GAAGA,EAAI,aAAcK,EAAO,YAAa,GAC3CL,CACT,CACF",
6
- "names": ["SignerError", "SignerErrorCode", "DefaultTronSigner", "_DefaultTronSigner", "__name", "provider", "SignerError", "tx", "transaction", "signedTxn", "error", "SignerErrorCode", "tronTx"]
4
+ "sourcesContent": ["import type { GenericSigner, TronTransaction } from 'rango-types';\n\nimport { SignerError, SignerErrorCode } from 'rango-types';\n\n/*\n * TODO - replace with real type\n * tslint:disable-next-line: no-any\n */\ntype TronExternalProvider = any;\n\nexport class DefaultTronSigner implements GenericSigner<TronTransaction> {\n private provider: TronExternalProvider;\n\n constructor(provider: TronExternalProvider) {\n this.provider = provider;\n }\n\n static buildTx(tronTx: TronTransaction) {\n let tx = {};\n if (!!tronTx.txID) {\n tx = { ...tx, txID: tronTx.txID };\n }\n if (tronTx.visible !== undefined) {\n tx = { ...tx, visible: tronTx.visible };\n }\n if (!!tronTx.__payload__) {\n tx = { ...tx, __payload__: tronTx.__payload__ };\n }\n if (!!tronTx.raw_data) {\n tx = { ...tx, raw_data: tronTx.raw_data };\n }\n if (!!tronTx.raw_data_hex) {\n tx = { ...tx, raw_data_hex: tronTx.raw_data_hex };\n }\n return tx;\n }\n async signMessage(msg: string): Promise<string> {\n try {\n return await this.provider.tronWeb.trx.signMessageV2(msg);\n } catch (error) {\n throw new SignerError(SignerErrorCode.SIGN_TX_ERROR, undefined, error);\n }\n }\n\n async signAndSendTx(tx: TronTransaction): Promise<{ hash: string }> {\n try {\n const transaction = DefaultTronSigner.buildTx(tx);\n const signedTxn = await this.provider.tronWeb.trx.sign(transaction);\n const receipt = await this.provider.tronWeb.trx.sendRawTransaction(\n signedTxn\n );\n const hash = receipt?.transaction?.txID;\n return { hash };\n } catch (error) {\n throw new SignerError(SignerErrorCode.SEND_TX_ERROR, undefined, error);\n }\n }\n}\n"],
5
+ "mappings": "+EAEA,OAAS,eAAAA,EAAa,mBAAAC,MAAuB,cAQtC,IAAMC,EAAN,MAAMC,CAA4D,CAVzE,MAUyE,CAAAC,EAAA,0BAGvE,YAAYC,EAAgC,CAC1C,KAAK,SAAWA,CAClB,CAEA,OAAO,QAAQC,EAAyB,CACtC,IAAIC,EAAK,CAAC,EACV,OAAMD,EAAO,OACXC,EAAK,CAAE,GAAGA,EAAI,KAAMD,EAAO,IAAK,GAE9BA,EAAO,UAAY,SACrBC,EAAK,CAAE,GAAGA,EAAI,QAASD,EAAO,OAAQ,GAElCA,EAAO,cACXC,EAAK,CAAE,GAAGA,EAAI,YAAaD,EAAO,WAAY,GAE1CA,EAAO,WACXC,EAAK,CAAE,GAAGA,EAAI,SAAUD,EAAO,QAAS,GAEpCA,EAAO,eACXC,EAAK,CAAE,GAAGA,EAAI,aAAcD,EAAO,YAAa,GAE3CC,CACT,CACA,MAAM,YAAYC,EAA8B,CAC9C,GAAI,CACF,OAAO,MAAM,KAAK,SAAS,QAAQ,IAAI,cAAcA,CAAG,CAC1D,OAASC,EAAO,CACd,MAAM,IAAIC,EAAYC,EAAgB,cAAe,OAAWF,CAAK,CACvE,CACF,CAEA,MAAM,cAAcF,EAAgD,CAClE,GAAI,CACF,IAAMK,EAAcT,EAAkB,QAAQI,CAAE,EAC1CM,EAAY,MAAM,KAAK,SAAS,QAAQ,IAAI,KAAKD,CAAW,EAKlE,MAAO,CAAE,MAJO,MAAM,KAAK,SAAS,QAAQ,IAAI,mBAC9CC,CACF,IACsB,aAAa,IACrB,CAChB,OAASJ,EAAO,CACd,MAAM,IAAIC,EAAYC,EAAgB,cAAe,OAAWF,CAAK,CACvE,CACF,CACF",
6
+ "names": ["SignerError", "SignerErrorCode", "DefaultTronSigner", "_DefaultTronSigner", "__name", "provider", "tronTx", "tx", "msg", "error", "SignerError", "SignerErrorCode", "transaction", "signedTxn"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/signer.ts":{"bytes":1488,"imports":[{"path":"rango-types","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":46,"imports":[{"path":"src/signer.ts","kind":"import-statement","original":"./signer"}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":2616},"dist/index.js":{"imports":[{"path":"rango-types","kind":"import-statement","external":true}],"exports":["DefaultTronSigner"],"entryPoint":"src/index.ts","inputs":{"src/signer.ts":{"bytesInOutput":697},"src/index.ts":{"bytesInOutput":0}},"bytes":842}}}
1
+ {"inputs":{"src/signer.ts":{"bytes":1693,"imports":[{"path":"rango-types","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":46,"imports":[{"path":"src/signer.ts","kind":"import-statement","original":"./signer"}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":2943},"dist/index.js":{"imports":[{"path":"rango-types","kind":"import-statement","external":true}],"exports":["DefaultTronSigner"],"entryPoint":"src/index.ts","inputs":{"src/signer.ts":{"bytesInOutput":764},"src/index.ts":{"bytesInOutput":0}},"bytes":909}}}
package/dist/signer.d.ts CHANGED
@@ -3,11 +3,11 @@ type TronExternalProvider = any;
3
3
  export declare class DefaultTronSigner implements GenericSigner<TronTransaction> {
4
4
  private provider;
5
5
  constructor(provider: TronExternalProvider);
6
- signMessage(): Promise<string>;
6
+ static buildTx(tronTx: TronTransaction): {};
7
+ signMessage(msg: string): Promise<string>;
7
8
  signAndSendTx(tx: TronTransaction): Promise<{
8
9
  hash: string;
9
10
  }>;
10
- static buildTx(tronTx: TronTransaction): {};
11
11
  }
12
12
  export {};
13
13
  //# sourceMappingURL=signer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAMlE,KAAK,oBAAoB,GAAG,GAAG,CAAC;AAEhC,qBAAa,iBAAkB,YAAW,aAAa,CAAC,eAAe,CAAC;IACtE,OAAO,CAAC,QAAQ,CAAuB;gBAE3B,QAAQ,EAAE,oBAAoB;IAIpC,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAI9B,aAAa,CAAC,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAcnE,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,eAAe;CAUvC"}
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAQlE,KAAK,oBAAoB,GAAG,GAAG,CAAC;AAEhC,qBAAa,iBAAkB,YAAW,aAAa,CAAC,eAAe,CAAC;IACtE,OAAO,CAAC,QAAQ,CAAuB;gBAE3B,QAAQ,EAAE,oBAAoB;IAI1C,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,eAAe;IAmBhC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQzC,aAAa,CAAC,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAapE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/signer-tron",
3
- "version": "0.27.1-next.1",
3
+ "version": "0.28.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
package/src/signer.ts CHANGED
@@ -2,8 +2,10 @@ import type { GenericSigner, TronTransaction } from 'rango-types';
2
2
 
3
3
  import { SignerError, SignerErrorCode } from 'rango-types';
4
4
 
5
- // TODO - replace with real type
6
- // tslint:disable-next-line: no-any
5
+ /*
6
+ * TODO - replace with real type
7
+ * tslint:disable-next-line: no-any
8
+ */
7
9
  type TronExternalProvider = any;
8
10
 
9
11
  export class DefaultTronSigner implements GenericSigner<TronTransaction> {
@@ -13,8 +15,31 @@ export class DefaultTronSigner implements GenericSigner<TronTransaction> {
13
15
  this.provider = provider;
14
16
  }
15
17
 
16
- async signMessage(): Promise<string> {
17
- throw SignerError.UnimplementedError('signMessage');
18
+ static buildTx(tronTx: TronTransaction) {
19
+ let tx = {};
20
+ if (!!tronTx.txID) {
21
+ tx = { ...tx, txID: tronTx.txID };
22
+ }
23
+ if (tronTx.visible !== undefined) {
24
+ tx = { ...tx, visible: tronTx.visible };
25
+ }
26
+ if (!!tronTx.__payload__) {
27
+ tx = { ...tx, __payload__: tronTx.__payload__ };
28
+ }
29
+ if (!!tronTx.raw_data) {
30
+ tx = { ...tx, raw_data: tronTx.raw_data };
31
+ }
32
+ if (!!tronTx.raw_data_hex) {
33
+ tx = { ...tx, raw_data_hex: tronTx.raw_data_hex };
34
+ }
35
+ return tx;
36
+ }
37
+ async signMessage(msg: string): Promise<string> {
38
+ try {
39
+ return await this.provider.tronWeb.trx.signMessageV2(msg);
40
+ } catch (error) {
41
+ throw new SignerError(SignerErrorCode.SIGN_TX_ERROR, undefined, error);
42
+ }
18
43
  }
19
44
 
20
45
  async signAndSendTx(tx: TronTransaction): Promise<{ hash: string }> {
@@ -30,15 +55,4 @@ export class DefaultTronSigner implements GenericSigner<TronTransaction> {
30
55
  throw new SignerError(SignerErrorCode.SEND_TX_ERROR, undefined, error);
31
56
  }
32
57
  }
33
-
34
- static buildTx(tronTx: TronTransaction) {
35
- let tx = {};
36
- if (!!tronTx.txID) tx = { ...tx, txID: tronTx.txID };
37
- if (tronTx.visible !== undefined) tx = { ...tx, visible: tronTx.visible };
38
- if (!!tronTx.__payload__) tx = { ...tx, __payload__: tronTx.__payload__ };
39
- if (!!tronTx.raw_data) tx = { ...tx, raw_data: tronTx.raw_data };
40
- if (!!tronTx.raw_data_hex)
41
- tx = { ...tx, raw_data_hex: tronTx.raw_data_hex };
42
- return tx;
43
- }
44
58
  }