@magic-ext/solana 3.1.0 → 3.1.1-beta.1
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/es/index.js +23 -51
- package/dist/es/index.js.map +1 -1
- package/package.json +1 -1
package/dist/es/index.js
CHANGED
|
@@ -1,79 +1,51 @@
|
|
|
1
1
|
/* eslint-disable no-param-reassign, array-callback-return */
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
var __assign = (this && this.__assign) || function () {
|
|
16
|
-
__assign = Object.assign || function(t) {
|
|
17
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18
|
-
s = arguments[i];
|
|
19
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
20
|
-
t[p] = s[p];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
|
-
return __assign.apply(this, arguments);
|
|
25
|
-
};
|
|
26
2
|
import { Extension } from 'magic-sdk';
|
|
27
3
|
import { SolanaPayloadMethod } from './type';
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
instructions.map(function (instruction) {
|
|
4
|
+
export class SolanaExtension extends Extension.Internal {
|
|
5
|
+
constructor(solanaConfig) {
|
|
6
|
+
super();
|
|
7
|
+
this.solanaConfig = solanaConfig;
|
|
8
|
+
this.name = 'solana';
|
|
9
|
+
this.config = {};
|
|
10
|
+
this.sendAndConfirmTransaction = (transaction, options) => {
|
|
11
|
+
const { instructions } = transaction;
|
|
12
|
+
instructions.map((instruction) => {
|
|
38
13
|
instruction.programId = instruction.programId.toBase58();
|
|
39
14
|
});
|
|
40
|
-
return
|
|
15
|
+
return this.request({
|
|
41
16
|
id: 42,
|
|
42
17
|
jsonrpc: '2.0',
|
|
43
18
|
method: SolanaPayloadMethod.SendTransaction,
|
|
44
19
|
params: {
|
|
45
|
-
instructions
|
|
46
|
-
options
|
|
20
|
+
instructions,
|
|
21
|
+
options,
|
|
47
22
|
},
|
|
48
23
|
});
|
|
49
24
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return
|
|
54
|
-
return
|
|
25
|
+
this.signTransaction = (transaction, serializeConfig) => {
|
|
26
|
+
const { instructions } = transaction;
|
|
27
|
+
const magicInstructions = instructions.map((i) => {
|
|
28
|
+
return Object.assign(Object.assign({}, i), { keys: i.keys.map((k) => {
|
|
29
|
+
return Object.assign(Object.assign({}, k), { pubkey: k.pubkey.toBase58() });
|
|
55
30
|
}), programId: i.programId.toBase58() });
|
|
56
31
|
});
|
|
57
|
-
|
|
32
|
+
const params = {
|
|
58
33
|
feePayer: transaction.feePayer.toBase58(),
|
|
59
34
|
instructions: magicInstructions,
|
|
60
35
|
recentBlockhash: transaction.recentBlockhash,
|
|
61
|
-
serializeConfig
|
|
36
|
+
serializeConfig,
|
|
62
37
|
};
|
|
63
|
-
return
|
|
38
|
+
return this.request({
|
|
64
39
|
id: 42,
|
|
65
40
|
jsonrpc: '2.0',
|
|
66
41
|
method: SolanaPayloadMethod.SignTransaction,
|
|
67
|
-
params
|
|
42
|
+
params,
|
|
68
43
|
});
|
|
69
44
|
};
|
|
70
|
-
|
|
45
|
+
this.config = {
|
|
71
46
|
rpcUrl: solanaConfig.rpcUrl,
|
|
72
47
|
chainType: 'SOLANA',
|
|
73
48
|
};
|
|
74
|
-
return _this;
|
|
75
49
|
}
|
|
76
|
-
|
|
77
|
-
}(Extension.Internal));
|
|
78
|
-
export { SolanaExtension };
|
|
50
|
+
}
|
|
79
51
|
//# sourceMappingURL=index.js.map
|
package/dist/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,6DAA6D
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAgB,mBAAmB,EAAmB,MAAM,QAAQ,CAAC;AAE5E,MAAM,OAAO,eAAgB,SAAQ,SAAS,CAAC,QAAuB;IAIpE,YAAmB,YAA0B;QAC3C,KAAK,EAAE,CAAC;QADS,iBAAY,GAAZ,YAAY,CAAc;QAH7C,SAAI,GAAG,QAAiB,CAAC;QACzB,WAAM,GAAQ,EAAE,CAAC;QAWV,8BAAyB,GAAG,CAAC,WAAgB,EAAE,OAAa,EAAE,EAAE;YACrE,MAAM,EAAE,YAAY,EAAE,GAAG,WAAW,CAAC;YAErC,YAAY,CAAC,GAAG,CAAC,CAAC,WAAgB,EAAE,EAAE;gBACpC,WAAW,CAAC,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;YAC3D,CAAC,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC,OAAO,CAAC;gBAClB,EAAE,EAAE,EAAE;gBACN,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,mBAAmB,CAAC,eAAe;gBAC3C,MAAM,EAAE;oBACN,YAAY;oBACZ,OAAO;iBACR;aACF,CAAC,CAAC;QACL,CAAC,CAAC;QAEK,oBAAe,GAAG,CAAC,WAAgB,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