@typesol/cli 0.24.0 → 0.25.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/CHANGELOG.md +46 -2
- package/README.md +10 -7
- package/dist/clientgen.js +36 -21
- package/dist/compiler/analyze.js +32 -2
- package/dist/compiler/emit/base.d.ts +10 -0
- package/dist/compiler/emit/base.js +8 -0
- package/dist/compiler/emit/calls.js +10 -10
- package/dist/compiler/emit/cpi.d.ts +10 -1
- package/dist/compiler/emit/cpi.js +182 -166
- package/dist/compiler/emit/function.d.ts +9 -0
- package/dist/compiler/emit/function.js +169 -139
- package/dist/compiler/emit/program.js +3 -0
- package/dist/compiler/emit/shared.d.ts +1 -0
- package/dist/compiler/emit/shared.js +1 -0
- package/dist/compiler/emit/statements.d.ts +6 -0
- package/dist/compiler/emit/statements.js +35 -5
- package/docs/architecture.md +26 -2
- package/docs/case-study-escrow.md +224 -0
- package/docs/errors.md +26 -1
- package/docs/language.md +12 -8
- package/docs/migrate-from-anchor.md +3 -1
- package/docs/runtime.md +59 -0
- package/lib/typesol.d.ts +35 -13
- package/package.json +1 -1
- package/runtime/typesol_rt.h +85 -14
|
@@ -207,6 +207,7 @@ export class CpiEmitter extends CallEmitter {
|
|
|
207
207
|
ts.isPostfixUnaryExpression(n) ||
|
|
208
208
|
ts.forEachChild(n, mutates) === true;
|
|
209
209
|
const inPlace = !node.elements.some(mutates);
|
|
210
|
+
const mark = this.lines.length;
|
|
210
211
|
for (const el of node.elements) {
|
|
211
212
|
const desc = this.describeSeed(el);
|
|
212
213
|
if (!desc)
|
|
@@ -252,9 +253,19 @@ export class CpiEmitter extends CallEmitter {
|
|
|
252
253
|
else
|
|
253
254
|
this.fail(el, "seeds can be strings, Pubkeys, integers or unit enum values");
|
|
254
255
|
}
|
|
256
|
+
// The same list again (escrow: the vault transfer, then its close) reuses the array declared for the first, when
|
|
257
|
+
// nothing was copied into temporaries (every entry points at a literal or at the place itself, so the array reads
|
|
258
|
+
// what a new one would), it has no spare slot (callers never write into those arrays) and it is still in scope.
|
|
259
|
+
const key = parts.join(", ");
|
|
260
|
+
const reusable = extra === 0 && parts.length > 0 && this.lines.length === mark;
|
|
261
|
+
const known = reusable ? this.seedArrays.get(key) : undefined;
|
|
262
|
+
if (known && this.scopes.includes(known.scope) && this.lines[known.at]?.trim() === known.text)
|
|
263
|
+
return { name: known.name, count: parts.length, idl };
|
|
255
264
|
const name = this.tmp("seeds");
|
|
256
265
|
const slots = parts.length + extra;
|
|
257
266
|
this.line(`SolSignerSeed ${name}[${Math.max(slots, 1)}] = {${parts.join(", ")}};`);
|
|
267
|
+
if (reusable)
|
|
268
|
+
this.seedArrays.set(key, { name, scope: this.scopes[this.scopes.length - 1], at: this.lines.length - 1, text: this.lines.at(-1).trim() });
|
|
258
269
|
return { name, count: parts.length, idl };
|
|
259
270
|
}
|
|
260
271
|
describeSeed(el) {
|
|
@@ -763,6 +774,10 @@ export class CpiEmitter extends CallEmitter {
|
|
|
763
774
|
const ataProgram = need("ataProgram", "an AssociatedTokenProgram");
|
|
764
775
|
const system = need("system", "a SystemProgram");
|
|
765
776
|
const tokenProgram = need("tokenProgram", "a token program (TokenProgram, Token2022Program or TokenInterface)");
|
|
777
|
+
// The address is derived under the token program: with two, which one the mint uses is not known here.
|
|
778
|
+
const tokenPrograms = this.ix.accounts.filter((o) => o.kind.kind === "tokenProgram");
|
|
779
|
+
if (tokenPrograms.length > 1)
|
|
780
|
+
this.fail(node, `${call}(...) needs exactly one token program parameter (found ${tokenPrograms.map((o) => o.name).join(", ")}); use TokenInterface`);
|
|
766
781
|
const { owner, mint } = target.constraints.ata;
|
|
767
782
|
const a = `a_${target.name}`;
|
|
768
783
|
const create = `TS_TRY(ts_ata_create(params, a_${ataProgram.name}, a_${payer.name}, ${a}, a_${owner}, a_${mint}, a_${system.name}, a_${tokenProgram.name}, false));`;
|
|
@@ -1715,179 +1730,180 @@ export class CpiEmitter extends CallEmitter {
|
|
|
1715
1730
|
});
|
|
1716
1731
|
return [{ bytes: [1, els.length & 0xff, 0, 0, 0] }, ...els.flatMap((e) => this.corePlugin(e, true))];
|
|
1717
1732
|
}
|
|
1718
|
-
/**
|
|
1733
|
+
/**
|
|
1734
|
+
* Metaplex Core: assets and collections (with plugins), plugins and external plugin adapters added, updated, written
|
|
1735
|
+
* and removed, transfer and burn. Each method is a row of CORE_OPS below: its accounts in order, its data.
|
|
1736
|
+
*/
|
|
1719
1737
|
coreOp(node, core, method) {
|
|
1720
1738
|
const a = node.arguments;
|
|
1721
1739
|
const p = `a_${core.name}`;
|
|
1722
|
-
const
|
|
1723
|
-
|
|
1724
|
-
|
|
1740
|
+
const op = this.coreOps()[method];
|
|
1741
|
+
if (!op)
|
|
1742
|
+
this.fail(node.expression, `Metaplex Core supports createAsset, createCollection, addPlugin, updatePlugin, removePlugin, addExternalPlugin, removeExternalPlugin, writeExternalPluginData (and the Collection forms), transferAsset and burnAsset, not ${method}`);
|
|
1743
|
+
// An array literal of object literals right after the fixed arguments is the plugin list; the signer seeds follow.
|
|
1725
1744
|
const isPlugins = (n) => !!n && ts.isArrayLiteralExpression(n) && (n.elements.length === 0 || n.elements.every((e) => ts.isObjectLiteralExpression(e)));
|
|
1726
|
-
const
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1745
|
+
const list = op.plugins && isPlugins(a[op.args]) ? a[op.args] : undefined;
|
|
1746
|
+
const seedsAt = op.args + (list ? 1 : 0);
|
|
1747
|
+
if (op.plugins ? a.length < op.args || a.length > seedsAt + 1 : a.length !== op.args && a.length !== op.args + 1)
|
|
1748
|
+
this.fail(node, op.usage(method));
|
|
1749
|
+
const metas = op.metas.map((m) => (m === "self" ? [p, false, false] : this.mplMeta(a[m[0]], core, m[1], m[2], m[3])));
|
|
1750
|
+
const data = this.mplData(node, op.max, op.data(a, list));
|
|
1751
|
+
this.cpi(p, metas, data.buf, data.len, a[seedsAt] ? this.signingSeeds(a[seedsAt]) : { name: "NULL", count: 0 });
|
|
1752
|
+
return undefined;
|
|
1753
|
+
}
|
|
1754
|
+
/**
|
|
1755
|
+
* Core instructions: `args` fixed arguments (then an optional plugin list when `plugins`, then optional signer
|
|
1756
|
+
* seeds), accounts in order (`[argument, label, writable, signer]`, or "self": the Core program, Core's "none" for an
|
|
1757
|
+
* optional account), at most `max` bytes of data.
|
|
1758
|
+
*/
|
|
1759
|
+
coreOps() {
|
|
1760
|
+
const str = (n) => ({ value: n, type: STRING });
|
|
1761
|
+
const asset = [0, "the asset", true, false];
|
|
1762
|
+
const assetPlugin = {
|
|
1763
|
+
usage: (m) => `${m}(asset, collection | null, payer, authority | null, systemProgram, ${m === "removePlugin" ? "kind" : "plugin"}, signerSeeds?)`,
|
|
1764
|
+
args: 6,
|
|
1765
|
+
// Add/Remove/UpdatePluginV1: asset, collection, payer, authority, systemProgram, logWrapper.
|
|
1766
|
+
metas: [
|
|
1767
|
+
asset,
|
|
1768
|
+
[1, "the collection", true, false],
|
|
1769
|
+
[2, "the payer", true, true],
|
|
1770
|
+
[3, "the authority", false, true],
|
|
1771
|
+
[4, "the system program", false, false],
|
|
1772
|
+
"self",
|
|
1773
|
+
],
|
|
1774
|
+
max: 2048,
|
|
1775
|
+
};
|
|
1776
|
+
const collectionPlugin = {
|
|
1777
|
+
usage: (m) => `${m}(collection, payer, authority | null, systemProgram, ${m === "removeCollectionPlugin" ? "kind" : "plugin"}, signerSeeds?)`,
|
|
1778
|
+
args: 5,
|
|
1779
|
+
// Add/Remove/UpdateCollectionPluginV1: collection, payer, authority, systemProgram, logWrapper.
|
|
1780
|
+
metas: [
|
|
1781
|
+
[0, "the collection", true, false],
|
|
1782
|
+
[1, "the payer", true, true],
|
|
1783
|
+
[2, "the authority", false, true],
|
|
1784
|
+
[3, "the system program", false, false],
|
|
1785
|
+
"self",
|
|
1786
|
+
],
|
|
1787
|
+
max: 2048,
|
|
1788
|
+
};
|
|
1789
|
+
const assetPluginOp = (method, disc) => ({
|
|
1790
|
+
...assetPlugin,
|
|
1791
|
+
data: (a) => [
|
|
1792
|
+
{ bytes: [disc] },
|
|
1793
|
+
...(method === "removePlugin" ? [this.corePluginType(a[5])] : this.corePlugin(a[5], method === "addPlugin")),
|
|
1794
|
+
],
|
|
1795
|
+
});
|
|
1796
|
+
const collectionPluginOp = (method, disc) => ({
|
|
1797
|
+
...collectionPlugin,
|
|
1798
|
+
data: (a) => [
|
|
1799
|
+
{ bytes: [disc] },
|
|
1800
|
+
...(method === "removeCollectionPlugin" ? [this.corePluginType(a[4])] : this.corePlugin(a[4], method === "addCollectionPlugin")),
|
|
1801
|
+
],
|
|
1802
|
+
});
|
|
1803
|
+
// Add/RemoveExternalPluginAdapterV1: asset, collection, payer, authority, systemProgram, logWrapper; the write has a
|
|
1804
|
+
// buffer account (left out: the data is in the instruction) before systemProgram. The Collection forms drop the asset.
|
|
1805
|
+
const external = (method, disc, collection) => {
|
|
1806
|
+
const write = method.startsWith("write");
|
|
1807
|
+
const add = method.startsWith("add");
|
|
1808
|
+
const n = (collection ? 5 : 6) + (write ? 1 : 0);
|
|
1809
|
+
const at = collection ? 4 : 5;
|
|
1810
|
+
const head = collection ? "collection, payer, authority | null, systemProgram" : "asset, collection | null, payer, authority | null, systemProgram";
|
|
1811
|
+
const metas = collection
|
|
1812
|
+
? [
|
|
1813
|
+
[0, "the collection", true, false],
|
|
1814
|
+
[1, "the payer", true, true],
|
|
1815
|
+
[2, "the authority", false, true],
|
|
1816
|
+
]
|
|
1817
|
+
: [asset, [1, "the collection", true, false], [2, "the payer", true, true], [3, "the authority", false, true]];
|
|
1818
|
+
if (write)
|
|
1819
|
+
metas.push("self");
|
|
1820
|
+
metas.push([collection ? 3 : 4, "the system program", false, false], "self");
|
|
1821
|
+
return {
|
|
1822
|
+
usage: (m) => `${m}(${head}, ${add ? "plugin" : write ? "key, data" : "key"}, signerSeeds?)`,
|
|
1823
|
+
args: n,
|
|
1824
|
+
metas,
|
|
1825
|
+
max: 1024,
|
|
1826
|
+
data: (a) => [
|
|
1827
|
+
{ bytes: [disc] },
|
|
1828
|
+
...(add
|
|
1829
|
+
? this.coreExternalPlugin(a[at])
|
|
1830
|
+
: write
|
|
1831
|
+
? [...this.coreExternalKey(a[at]), ...this.coreExternalData(a[at + 1])]
|
|
1832
|
+
: this.coreExternalKey(a[at])),
|
|
1833
|
+
],
|
|
1834
|
+
};
|
|
1835
|
+
};
|
|
1836
|
+
return {
|
|
1837
|
+
createAsset: {
|
|
1838
|
+
usage: () => "createAsset(asset, collection | null, authority | null, payer, owner | null, systemProgram, name, uri, plugins?, signerSeeds?)",
|
|
1839
|
+
args: 8,
|
|
1840
|
+
plugins: true,
|
|
1841
|
+
// CreateV1: asset, collection, authority, payer, owner, updateAuthority (the collection's, or the payer by
|
|
1842
|
+
// default), systemProgram, logWrapper.
|
|
1843
|
+
metas: [
|
|
1844
|
+
[0, "the asset", true, true],
|
|
1845
|
+
[1, "the collection", true, false],
|
|
1846
|
+
[2, "the collection authority", false, true],
|
|
1847
|
+
[3, "the payer", true, true],
|
|
1848
|
+
[4, "the owner", false, false],
|
|
1849
|
+
"self",
|
|
1850
|
+
[5, "the system program", false, false],
|
|
1851
|
+
"self",
|
|
1852
|
+
],
|
|
1853
|
+
max: 2048,
|
|
1854
|
+
data: (a, plugins) => [{ bytes: [0, 0] }, str(a[6]), str(a[7]), ...this.corePluginList(plugins)],
|
|
1855
|
+
},
|
|
1856
|
+
createCollection: {
|
|
1857
|
+
usage: () => "createCollection(collection, updateAuthority | null, payer, systemProgram, name, uri, plugins?, signerSeeds?)",
|
|
1858
|
+
args: 6,
|
|
1859
|
+
plugins: true,
|
|
1748
1860
|
// CreateCollectionV1: collection, updateAuthority, payer, systemProgram.
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
if (a.length !== 6 && a.length !== 7)
|
|
1768
|
-
this.fail(node, `${method}(asset, collection | null, payer, authority | null, systemProgram, ${last}, signerSeeds?)`);
|
|
1769
|
-
const metas = [
|
|
1770
|
-
this.mplMeta(a[0], core, "the asset", true, false),
|
|
1771
|
-
this.mplMeta(a[1], core, "the collection", true, false),
|
|
1772
|
-
this.mplMeta(a[2], core, "the payer", true, true),
|
|
1773
|
-
this.mplMeta(a[3], core, "the authority", false, true),
|
|
1774
|
-
this.mplMeta(a[4], core, "the system program", false, false),
|
|
1775
|
-
self,
|
|
1776
|
-
];
|
|
1777
|
-
const body = method === "removePlugin" ? [this.corePluginType(a[5])] : this.corePlugin(a[5], method === "addPlugin");
|
|
1778
|
-
const data = this.mplData(node, 2048, [{ bytes: [{ addPlugin: 2, removePlugin: 4, updatePlugin: 6 }[method]] }, ...body]);
|
|
1779
|
-
this.cpi(p, metas, data.buf, data.len, seedsAt(6));
|
|
1780
|
-
return undefined;
|
|
1781
|
-
}
|
|
1782
|
-
case "addCollectionPlugin":
|
|
1783
|
-
case "updateCollectionPlugin":
|
|
1784
|
-
case "removeCollectionPlugin": {
|
|
1785
|
-
// Add/Remove/UpdateCollectionPluginV1: collection, payer, authority, systemProgram, logWrapper.
|
|
1786
|
-
const last = method === "removeCollectionPlugin" ? "kind" : "plugin";
|
|
1787
|
-
if (a.length !== 5 && a.length !== 6)
|
|
1788
|
-
this.fail(node, `${method}(collection, payer, authority | null, systemProgram, ${last}, signerSeeds?)`);
|
|
1789
|
-
const metas = [
|
|
1790
|
-
this.mplMeta(a[0], core, "the collection", true, false),
|
|
1791
|
-
this.mplMeta(a[1], core, "the payer", true, true),
|
|
1792
|
-
this.mplMeta(a[2], core, "the authority", false, true),
|
|
1793
|
-
this.mplMeta(a[3], core, "the system program", false, false),
|
|
1794
|
-
self,
|
|
1795
|
-
];
|
|
1796
|
-
const body = method === "removeCollectionPlugin" ? [this.corePluginType(a[4])] : this.corePlugin(a[4], method === "addCollectionPlugin");
|
|
1797
|
-
const data = this.mplData(node, 2048, [{ bytes: [{ addCollectionPlugin: 3, removeCollectionPlugin: 5, updateCollectionPlugin: 7 }[method]] }, ...body]);
|
|
1798
|
-
this.cpi(p, metas, data.buf, data.len, seedsAt(5));
|
|
1799
|
-
return undefined;
|
|
1800
|
-
}
|
|
1801
|
-
case "transferAsset": {
|
|
1861
|
+
metas: [
|
|
1862
|
+
[0, "the collection", true, true],
|
|
1863
|
+
[1, "the update authority", false, false],
|
|
1864
|
+
[2, "the payer", true, true],
|
|
1865
|
+
[3, "the system program", false, false],
|
|
1866
|
+
],
|
|
1867
|
+
max: 2048,
|
|
1868
|
+
data: (a, plugins) => [{ bytes: [1] }, str(a[4]), str(a[5]), ...this.corePluginList(plugins)],
|
|
1869
|
+
},
|
|
1870
|
+
addPlugin: assetPluginOp("addPlugin", 2),
|
|
1871
|
+
removePlugin: assetPluginOp("removePlugin", 4),
|
|
1872
|
+
updatePlugin: assetPluginOp("updatePlugin", 6),
|
|
1873
|
+
addCollectionPlugin: collectionPluginOp("addCollectionPlugin", 3),
|
|
1874
|
+
removeCollectionPlugin: collectionPluginOp("removeCollectionPlugin", 5),
|
|
1875
|
+
updateCollectionPlugin: collectionPluginOp("updateCollectionPlugin", 7),
|
|
1876
|
+
transferAsset: {
|
|
1877
|
+
usage: () => "transferAsset(asset, collection | null, payer, authority | null, newOwner, signerSeeds?)",
|
|
1878
|
+
args: 5,
|
|
1802
1879
|
// TransferV1: asset, collection, payer, authority, newOwner, systemProgram, logWrapper.
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
]
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
case "burnAsset": {
|
|
1880
|
+
metas: [
|
|
1881
|
+
asset,
|
|
1882
|
+
[1, "the collection", false, false],
|
|
1883
|
+
[2, "the payer", true, true],
|
|
1884
|
+
[3, "the authority", false, true],
|
|
1885
|
+
[4, "the new owner", false, false],
|
|
1886
|
+
"self",
|
|
1887
|
+
"self",
|
|
1888
|
+
],
|
|
1889
|
+
max: 8,
|
|
1890
|
+
data: () => [{ bytes: [14, 0] }],
|
|
1891
|
+
},
|
|
1892
|
+
burnAsset: {
|
|
1893
|
+
usage: () => "burnAsset(asset, collection | null, payer, authority | null, signerSeeds?)",
|
|
1894
|
+
args: 4,
|
|
1819
1895
|
// BurnV1: asset, collection, payer, authority, systemProgram, logWrapper.
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
this.cpi(p, metas, data.buf, data.len, seedsAt(4));
|
|
1832
|
-
return undefined;
|
|
1833
|
-
}
|
|
1834
|
-
case "addExternalPlugin":
|
|
1835
|
-
case "removeExternalPlugin":
|
|
1836
|
-
case "writeExternalPluginData": {
|
|
1837
|
-
// Add/RemoveExternalPluginAdapterV1: asset, collection, payer, authority, systemProgram, logWrapper;
|
|
1838
|
-
// WriteExternalPluginAdapterDataV1 has a buffer account (left out: the data is in the instruction) before systemProgram.
|
|
1839
|
-
const write = method === "writeExternalPluginData";
|
|
1840
|
-
const n = write ? 7 : 6;
|
|
1841
|
-
if (a.length !== n && a.length !== n + 1)
|
|
1842
|
-
this.fail(node, `${method}(asset, collection | null, payer, authority | null, systemProgram, ${method === "addExternalPlugin" ? "plugin" : write ? "key, data" : "key"}, signerSeeds?)`);
|
|
1843
|
-
const metas = [
|
|
1844
|
-
this.mplMeta(a[0], core, "the asset", true, false),
|
|
1845
|
-
this.mplMeta(a[1], core, "the collection", true, false),
|
|
1846
|
-
this.mplMeta(a[2], core, "the payer", true, true),
|
|
1847
|
-
this.mplMeta(a[3], core, "the authority", false, true),
|
|
1848
|
-
...(write ? [self] : []),
|
|
1849
|
-
this.mplMeta(a[4], core, "the system program", false, false),
|
|
1850
|
-
self,
|
|
1851
|
-
];
|
|
1852
|
-
const body = method === "addExternalPlugin"
|
|
1853
|
-
? this.coreExternalPlugin(a[5])
|
|
1854
|
-
: write
|
|
1855
|
-
? [...this.coreExternalKey(a[5]), ...this.coreExternalData(a[6])]
|
|
1856
|
-
: this.coreExternalKey(a[5]);
|
|
1857
|
-
const data = this.mplData(node, 1024, [{ bytes: [{ addExternalPlugin: 22, removeExternalPlugin: 24, writeExternalPluginData: 28 }[method]] }, ...body]);
|
|
1858
|
-
this.cpi(p, metas, data.buf, data.len, seedsAt(n));
|
|
1859
|
-
return undefined;
|
|
1860
|
-
}
|
|
1861
|
-
case "addCollectionExternalPlugin":
|
|
1862
|
-
case "removeCollectionExternalPlugin":
|
|
1863
|
-
case "writeCollectionExternalPluginData": {
|
|
1864
|
-
// The same on a collection: collection, payer, authority, (buffer,) systemProgram, logWrapper.
|
|
1865
|
-
const write = method === "writeCollectionExternalPluginData";
|
|
1866
|
-
const n = write ? 6 : 5;
|
|
1867
|
-
if (a.length !== n && a.length !== n + 1)
|
|
1868
|
-
this.fail(node, `${method}(collection, payer, authority | null, systemProgram, ${method === "addCollectionExternalPlugin" ? "plugin" : write ? "key, data" : "key"}, signerSeeds?)`);
|
|
1869
|
-
const metas = [
|
|
1870
|
-
this.mplMeta(a[0], core, "the collection", true, false),
|
|
1871
|
-
this.mplMeta(a[1], core, "the payer", true, true),
|
|
1872
|
-
this.mplMeta(a[2], core, "the authority", false, true),
|
|
1873
|
-
...(write ? [self] : []),
|
|
1874
|
-
this.mplMeta(a[3], core, "the system program", false, false),
|
|
1875
|
-
self,
|
|
1876
|
-
];
|
|
1877
|
-
const body = method === "addCollectionExternalPlugin"
|
|
1878
|
-
? this.coreExternalPlugin(a[4])
|
|
1879
|
-
: write
|
|
1880
|
-
? [...this.coreExternalKey(a[4]), ...this.coreExternalData(a[5])]
|
|
1881
|
-
: this.coreExternalKey(a[4]);
|
|
1882
|
-
const data = this.mplData(node, 1024, [
|
|
1883
|
-
{ bytes: [{ addCollectionExternalPlugin: 23, removeCollectionExternalPlugin: 25, writeCollectionExternalPluginData: 29 }[method]] },
|
|
1884
|
-
...body,
|
|
1885
|
-
]);
|
|
1886
|
-
this.cpi(p, metas, data.buf, data.len, seedsAt(n));
|
|
1887
|
-
return undefined;
|
|
1888
|
-
}
|
|
1889
|
-
}
|
|
1890
|
-
this.fail(node.expression, `Metaplex Core supports createAsset, createCollection, addPlugin, updatePlugin, removePlugin, addExternalPlugin, removeExternalPlugin, writeExternalPluginData (and the Collection forms), transferAsset and burnAsset, not ${method}`);
|
|
1896
|
+
metas: [asset, [1, "the collection", true, false], [2, "the payer", true, true], [3, "the authority", false, true], "self", "self"],
|
|
1897
|
+
max: 8,
|
|
1898
|
+
data: () => [{ bytes: [12, 0] }],
|
|
1899
|
+
},
|
|
1900
|
+
addExternalPlugin: external("addExternalPlugin", 22, false),
|
|
1901
|
+
removeExternalPlugin: external("removeExternalPlugin", 24, false),
|
|
1902
|
+
writeExternalPluginData: external("writeExternalPluginData", 28, false),
|
|
1903
|
+
addCollectionExternalPlugin: external("addCollectionExternalPlugin", 23, true),
|
|
1904
|
+
removeCollectionExternalPlugin: external("removeCollectionExternalPlugin", 25, true),
|
|
1905
|
+
writeCollectionExternalPluginData: external("writeCollectionExternalPluginData", 29, true),
|
|
1906
|
+
};
|
|
1891
1907
|
}
|
|
1892
1908
|
/** The fields of a Core object literal (`{ kind: "AppData", … }`) by name. */
|
|
1893
1909
|
coreProps(node, what) {
|
|
@@ -9,7 +9,16 @@ export declare class FunctionEmitter extends StatementEmitter {
|
|
|
9
9
|
emitInstruction(): string;
|
|
10
10
|
/** CloseTo<…> accounts are closed when the instruction succeeds, at every return. */
|
|
11
11
|
protected epilogue(): string[];
|
|
12
|
+
/**
|
|
13
|
+
* Each account's constraints, account by account in parameter order and, within one account, in Anchor's order
|
|
14
|
+
* (anchor-syn's `linearize`): seeds, associated token, has_one, owner, executable, address, token::, mint::.
|
|
15
|
+
* A transaction that breaks several checks then fails with the same error code as under Anchor.
|
|
16
|
+
*/
|
|
12
17
|
protected constraintChecks(ix: Instruction): string[];
|
|
18
|
+
/** Ata<…>: the account's owner (2015) and address (2009) as Anchor checks them, then its mint. */
|
|
19
|
+
private ataCheck;
|
|
20
|
+
/** Seeds<…>: the account is the PDA of its seeds (with the stored bump, or the canonical one found here). */
|
|
21
|
+
private seedsCheck;
|
|
13
22
|
/** Optional account parameters a piece of generated C refers to (a_name / d_name). */
|
|
14
23
|
protected optionalIn(code: string): string[];
|
|
15
24
|
}
|