Quellcode durchsuchen

Add delegate macro to delegate/undelegate components (#49)

* :sparkles: Add ability to delegate/undelegate components

* :wrench: Use local delegation.so

* :recycle: Refactor code

* :package: Update delegation.so

* :technologist: Add undelegate and unit tests

* :bug: Fix delegation program path
Gabriele Picco vor 1 Jahr
Ursprung
Commit
fd6bb8f0c8
34 geänderte Dateien mit 1256 neuen und 185 gelöschten Zeilen
  1. 18 0
      Anchor.toml
  2. 187 151
      Cargo.lock
  3. 3 0
      Cargo.toml
  4. 15 0
      clients/bolt-sdk/lib/delegation/accounts.d.ts
  5. 1 0
      clients/bolt-sdk/lib/delegation/accounts.d.ts.map
  6. 47 0
      clients/bolt-sdk/lib/delegation/accounts.js
  7. 1 0
      clients/bolt-sdk/lib/delegation/accounts.js.map
  8. 30 0
      clients/bolt-sdk/lib/delegation/delegate.d.ts
  9. 1 0
      clients/bolt-sdk/lib/delegation/delegate.d.ts.map
  10. 157 0
      clients/bolt-sdk/lib/delegation/delegate.js
  11. 1 0
      clients/bolt-sdk/lib/delegation/delegate.js.map
  12. 23 0
      clients/bolt-sdk/lib/delegation/undelegate.d.ts
  13. 1 0
      clients/bolt-sdk/lib/delegation/undelegate.d.ts.map
  14. 152 0
      clients/bolt-sdk/lib/delegation/undelegate.js
  15. 1 0
      clients/bolt-sdk/lib/delegation/undelegate.js.map
  16. 2 0
      clients/bolt-sdk/lib/index.d.ts
  17. 1 1
      clients/bolt-sdk/lib/index.d.ts.map
  18. 2 0
      clients/bolt-sdk/lib/index.js
  19. 0 0
      clients/bolt-sdk/lib/index.js.map
  20. 51 0
      clients/bolt-sdk/src/generated/delegation/accounts.ts
  21. 117 0
      clients/bolt-sdk/src/generated/delegation/delegate.ts
  22. 115 0
      clients/bolt-sdk/src/generated/delegation/undelegate.ts
  23. 2 0
      clients/bolt-sdk/src/generated/index.ts
  24. 4 0
      crates/bolt-lang/Cargo.toml
  25. 1 1
      crates/bolt-lang/attribute/bolt-program/src/lib.rs
  26. 61 30
      crates/bolt-lang/attribute/component/src/lib.rs
  27. 17 0
      crates/bolt-lang/attribute/delegate/Cargo.toml
  28. 176 0
      crates/bolt-lang/attribute/delegate/src/lib.rs
  29. 3 0
      crates/bolt-lang/src/lib.rs
  30. 1 1
      examples/component-position/src/lib.rs
  31. 37 1
      tests/bolt.ts
  32. 14 0
      tests/fixtures/commit_record.json
  33. 14 0
      tests/fixtures/committed_state.json
  34. BIN
      tests/fixtures/delegation.so

+ 18 - 0
Anchor.toml

@@ -23,8 +23,26 @@ url = "https://api.apr.dev"
 cluster = "localnet"
 cluster = "localnet"
 wallet = "./tests/fixtures/provider.json"
 wallet = "./tests/fixtures/provider.json"
 
 
+[test]
+startup_wait = 5000
+shutdown_wait = 2000
+upgradeable = false
+
 [workspace]
 [workspace]
 members = ["programs/bolt-component", "programs/bolt-system", "programs/world", "examples/component-position", "examples/component-velocity", "examples/system-apply-velocity", "examples/system-fly", "examples/system-simple-movement"]
 members = ["programs/bolt-component", "programs/bolt-system", "programs/world", "examples/component-position", "examples/component-velocity", "examples/system-apply-velocity", "examples/system-fly", "examples/system-simple-movement"]
 
 
+[[test.genesis]]
+address = "DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh"
+program = "tests/fixtures/delegation.so"
+upgradeable = false
+
+[[test.validator.account]]
+address = "EEmsg7GbxEAw5f9hGfZRmJRJ27HK8KeGDp7ViW9X2mYa"
+filename = "tests/fixtures/commit_record.json"
+
+[[test.validator.account]]
+address = "7nQvHcfEqtFmY2q6hiQbidu8BCNdqegnEFfH7HkByFn5"
+filename = "tests/fixtures/committed_state.json"
+
 [scripts]
 [scripts]
 test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/bolt.ts"
 test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/bolt.ts"

Datei-Diff unterdrückt, da er zu groß ist
+ 187 - 151
Cargo.lock


+ 3 - 0
Cargo.toml

@@ -16,6 +16,7 @@ edition = "2021"
 
 
 [workspace.dependencies]
 [workspace.dependencies]
 bolt-attribute-bolt-program = { path = "crates/bolt-lang/attribute/bolt-program", version = "=0.1.5" }
 bolt-attribute-bolt-program = { path = "crates/bolt-lang/attribute/bolt-program", version = "=0.1.5" }
+bolt-attribute-bolt-delegate = { path = "crates/bolt-lang/attribute/delegate", version = "=0.1.5" }
 bolt-attribute-bolt-component = { path = "crates/bolt-lang/attribute/component", version = "=0.1.5" }
 bolt-attribute-bolt-component = { path = "crates/bolt-lang/attribute/component", version = "=0.1.5" }
 bolt-attribute-bolt-system = { path = "crates/bolt-lang/attribute/system", version = "=0.1.5"}
 bolt-attribute-bolt-system = { path = "crates/bolt-lang/attribute/system", version = "=0.1.5"}
 bolt-attribute-bolt-system-input = { path = "crates/bolt-lang/attribute/system-input", version = "=0.1.5" }
 bolt-attribute-bolt-system-input = { path = "crates/bolt-lang/attribute/system-input", version = "=0.1.5" }
@@ -36,6 +37,7 @@ anchor-cli = { version = "=0.30.0" }
 anchor-client = { version = "=0.30.0" }
 anchor-client = { version = "=0.30.0" }
 anchor-syn = { version = "=0.30.0" }
 anchor-syn = { version = "=0.30.0" }
 anchor-lang-idl = { version = "=0.1.0" }
 anchor-lang-idl = { version = "=0.1.0" }
+solana-program = { version = "=1.18" }
 solana-client = { version = "=1.16" }
 solana-client = { version = "=1.16" }
 anchor-spl = { version = "=0.30.0" }
 anchor-spl = { version = "=0.30.0" }
 solana-security-txt = "1.1.1"
 solana-security-txt = "1.1.1"
@@ -49,6 +51,7 @@ anyhow = "1.0.32"
 heck = "0.5.0"
 heck = "0.5.0"
 clap = { version = "4.2.4", features = ["derive"] }
 clap = { version = "4.2.4", features = ["derive"] }
 ahash = "=0.8.11"
 ahash = "=0.8.11"
+delegation-program-sdk = "=0.0.2"
 
 
 [profile.release]
 [profile.release]
 overflow-checks = true
 overflow-checks = true

+ 15 - 0
clients/bolt-sdk/lib/delegation/accounts.d.ts

@@ -0,0 +1,15 @@
+import { PublicKey } from "@solana/web3.js";
+export declare const DELEGATION_PROGRAM_ID =
+  "DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh";
+export declare function getDelegationAccounts(
+  accountToDelegate: PublicKey,
+  ownerProgram: PublicKey,
+  ownedBuffer?: boolean
+): {
+  delegationPda: PublicKey;
+  delegatedAccountSeedsPda: PublicKey;
+  bufferPda: PublicKey;
+  commitStateRecordPda: PublicKey;
+  commitStatePda: PublicKey;
+};
+//# sourceMappingURL=accounts.d.ts.map

+ 1 - 0
clients/bolt-sdk/lib/delegation/accounts.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/generated/delegation/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAO5C,eAAO,MAAM,qBAAqB,iDACc,CAAC;AAEjD,wBAAgB,qBAAqB,CACnC,iBAAiB,EAAE,SAAS,EAC5B,YAAY,EAAE,SAAS,EACvB,WAAW,GAAE,OAAc;;;;;;EAqC5B"}

+ 47 - 0
clients/bolt-sdk/lib/delegation/accounts.js

@@ -0,0 +1,47 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.getDelegationAccounts = exports.DELEGATION_PROGRAM_ID = void 0;
+var web3_js_1 = require("@solana/web3.js");
+var SEED_BUFFER_PDA = "buffer";
+var SEED_DELEGATION_PDA = "delegation";
+var DELEGATED_ACCOUNT_SEEDS = "account-seeds";
+var SEED_COMMIT_STATE_RECORD_PDA = "commit-state-record";
+var SEED_STATE_DIFF_PDA = "state-diff";
+exports.DELEGATION_PROGRAM_ID = "DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh";
+function getDelegationAccounts(accountToDelegate, ownerProgram, ownedBuffer) {
+  if (ownedBuffer === void 0) {
+    ownedBuffer = true;
+  }
+  var pdaBytes = accountToDelegate.toBytes();
+  var delegationPda = web3_js_1.PublicKey.findProgramAddressSync(
+    [Buffer.from(SEED_DELEGATION_PDA), pdaBytes],
+    new web3_js_1.PublicKey(exports.DELEGATION_PROGRAM_ID)
+  )[0];
+  var delegatedAccountSeedsPda = web3_js_1.PublicKey.findProgramAddressSync(
+    [Buffer.from(DELEGATED_ACCOUNT_SEEDS), pdaBytes],
+    new web3_js_1.PublicKey(exports.DELEGATION_PROGRAM_ID)
+  )[0];
+  var bufferPda = web3_js_1.PublicKey.findProgramAddressSync(
+    [Buffer.from(SEED_BUFFER_PDA), pdaBytes],
+    ownedBuffer
+      ? new web3_js_1.PublicKey(ownerProgram)
+      : new web3_js_1.PublicKey(exports.DELEGATION_PROGRAM_ID)
+  )[0];
+  var commitStateRecordPda = web3_js_1.PublicKey.findProgramAddressSync(
+    [Buffer.from(SEED_COMMIT_STATE_RECORD_PDA), pdaBytes],
+    new web3_js_1.PublicKey(exports.DELEGATION_PROGRAM_ID)
+  )[0];
+  var commitStatePda = web3_js_1.PublicKey.findProgramAddressSync(
+    [Buffer.from(SEED_STATE_DIFF_PDA), pdaBytes],
+    new web3_js_1.PublicKey(exports.DELEGATION_PROGRAM_ID)
+  )[0];
+  return {
+    delegationPda: delegationPda,
+    delegatedAccountSeedsPda: delegatedAccountSeedsPda,
+    bufferPda: bufferPda,
+    commitStateRecordPda: commitStateRecordPda,
+    commitStatePda: commitStatePda,
+  };
+}
+exports.getDelegationAccounts = getDelegationAccounts;
+//# sourceMappingURL=accounts.js.map

+ 1 - 0
clients/bolt-sdk/lib/delegation/accounts.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../src/generated/delegation/accounts.ts"],"names":[],"mappings":";;;AAAA,2CAA4C;AAE5C,IAAM,eAAe,GAAG,QAAQ,CAAC;AACjC,IAAM,mBAAmB,GAAG,YAAY,CAAC;AACzC,IAAM,uBAAuB,GAAG,eAAe,CAAC;AAChD,IAAM,4BAA4B,GAAG,qBAAqB,CAAC;AAC3D,IAAM,mBAAmB,GAAG,YAAY,CAAC;AAC5B,QAAA,qBAAqB,GAChC,8CAA8C,CAA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,CAAC;AAxCD,sDAwCC"}

+ 30 - 0
clients/bolt-sdk/lib/delegation/delegate.d.ts

@@ -0,0 +1,30 @@
+import * as beet from "@metaplex-foundation/beet";
+import * as web3 from "@solana/web3.js";
+export interface DelegateInstructionArgs {
+  validUntil: beet.bignum;
+  commitFrequencyMs: number;
+}
+export declare const delegateStruct: beet.FixableBeetArgsStruct<
+  DelegateInstructionArgs & {
+    instructionDiscriminator: number[];
+  }
+>;
+export interface DelegateInstructionAccounts {
+  payer: web3.PublicKey;
+  entity: web3.PublicKey;
+  account: web3.PublicKey;
+  ownerProgram: web3.PublicKey;
+  buffer?: web3.PublicKey;
+  delegationRecord?: web3.PublicKey;
+  delegateAccountSeeds?: web3.PublicKey;
+  delegationProgram?: web3.PublicKey;
+  systemProgram?: web3.PublicKey;
+}
+export declare const delegateInstructionDiscriminator: number[];
+export declare function createDelegateInstruction(
+  accounts: DelegateInstructionAccounts,
+  validUntil?: beet.bignum,
+  commitFrequencyMs?: number,
+  programId?: web3.PublicKey
+): web3.TransactionInstruction;
+//# sourceMappingURL=delegate.d.ts.map

+ 1 - 0
clients/bolt-sdk/lib/delegation/delegate.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"delegate.d.ts","sourceRoot":"","sources":["../../src/generated/delegation/delegate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,2BAA2B,CAAC;AAClD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAGxC,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,cAAc;8BAEG,MAAM,EAAE;EASrC,CAAC;AAOF,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC;IACtB,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC;IACvB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;IACxB,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC;IAC7B,MAAM,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IACxB,gBAAgB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IAClC,oBAAoB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IACtC,iBAAiB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IACnC,aAAa,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;CAChC;AAED,eAAO,MAAM,gCAAgC,UAE5C,CAAC;AAMF,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,2BAA2B,EACrC,UAAU,GAAE,IAAI,CAAC,MAAU,EAC3B,iBAAiB,GAAE,MAAc,EACjC,SAAS,iBAAwB,+BAiElC"}

+ 157 - 0
clients/bolt-sdk/lib/delegation/delegate.js

@@ -0,0 +1,157 @@
+"use strict";
+var __createBinding =
+  (this && this.__createBinding) ||
+  (Object.create
+    ? function (o, m, k, k2) {
+        if (k2 === undefined) k2 = k;
+        var desc = Object.getOwnPropertyDescriptor(m, k);
+        if (
+          !desc ||
+          ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
+        ) {
+          desc = {
+            enumerable: true,
+            get: function () {
+              return m[k];
+            },
+          };
+        }
+        Object.defineProperty(o, k2, desc);
+      }
+    : function (o, m, k, k2) {
+        if (k2 === undefined) k2 = k;
+        o[k2] = m[k];
+      });
+var __setModuleDefault =
+  (this && this.__setModuleDefault) ||
+  (Object.create
+    ? function (o, v) {
+        Object.defineProperty(o, "default", { enumerable: true, value: v });
+      }
+    : function (o, v) {
+        o["default"] = v;
+      });
+var __importStar =
+  (this && this.__importStar) ||
+  function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null)
+      for (var k in mod)
+        if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
+          __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+  };
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.createDelegateInstruction =
+  exports.delegateInstructionDiscriminator =
+  exports.delegateStruct =
+    void 0;
+var beet = __importStar(require("@metaplex-foundation/beet"));
+var web3 = __importStar(require("@solana/web3.js"));
+var accounts_1 = require("./accounts");
+exports.delegateStruct = new beet.FixableBeetArgsStruct(
+  [
+    ["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)],
+    ["validUntil", beet.i64],
+    ["commitFrequencyMs", beet.u32],
+  ],
+  "DelegateInstructionArgs"
+);
+exports.delegateInstructionDiscriminator = [90, 147, 75, 178, 85, 88, 4, 137];
+function createDelegateInstruction(
+  accounts,
+  validUntil,
+  commitFrequencyMs,
+  programId
+) {
+  var _a, _b, _c, _d, _e;
+  if (validUntil === void 0) {
+    validUntil = 0;
+  }
+  if (commitFrequencyMs === void 0) {
+    commitFrequencyMs = 30000;
+  }
+  if (programId === void 0) {
+    programId = accounts.ownerProgram;
+  }
+  var data = exports.delegateStruct.serialize({
+    instructionDiscriminator: exports.delegateInstructionDiscriminator,
+    validUntil: validUntil,
+    commitFrequencyMs: commitFrequencyMs,
+  })[0];
+  var _f = (0, accounts_1.getDelegationAccounts)(
+      accounts.account,
+      accounts.ownerProgram
+    ),
+    delegationPda = _f.delegationPda,
+    delegatedAccountSeedsPda = _f.delegatedAccountSeedsPda,
+    bufferPda = _f.bufferPda;
+  var keys = [
+    {
+      pubkey: accounts.payer,
+      isWritable: false,
+      isSigner: true,
+    },
+    {
+      pubkey: accounts.entity,
+      isWritable: false,
+      isSigner: false,
+    },
+    {
+      pubkey: accounts.account,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey: accounts.ownerProgram,
+      isWritable: false,
+      isSigner: false,
+    },
+    {
+      pubkey: (_a = accounts.buffer) !== null && _a !== void 0 ? _a : bufferPda,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey:
+        (_b = accounts.delegationRecord) !== null && _b !== void 0
+          ? _b
+          : delegationPda,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey:
+        (_c = accounts.delegateAccountSeeds) !== null && _c !== void 0
+          ? _c
+          : delegatedAccountSeedsPda,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey:
+        (_d = accounts.delegationProgram) !== null && _d !== void 0
+          ? _d
+          : new web3.PublicKey(accounts_1.DELEGATION_PROGRAM_ID),
+      isWritable: false,
+      isSigner: false,
+    },
+    {
+      pubkey:
+        (_e = accounts.systemProgram) !== null && _e !== void 0
+          ? _e
+          : web3.SystemProgram.programId,
+      isWritable: false,
+      isSigner: false,
+    },
+  ];
+  return new web3.TransactionInstruction({
+    programId: programId,
+    keys: keys,
+    data: data,
+  });
+}
+exports.createDelegateInstruction = createDelegateInstruction;
+//# sourceMappingURL=delegate.js.map

+ 1 - 0
clients/bolt-sdk/lib/delegation/delegate.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"delegate.js","sourceRoot":"","sources":["../../src/generated/delegation/delegate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAkD;AAClD,oDAAwC;AACxC,uCAA0E;AAO7D,QAAA,cAAc,GAAG,IAAI,IAAI,CAAC,qBAAqB,CAK1D;IACE,CAAC,0BAA0B,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACpE,CAAC,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC;IACxB,CAAC,mBAAmB,EAAE,IAAI,CAAC,GAAG,CAAC;CAChC,EACD,yBAAyB,CAC1B,CAAC;AAmBW,QAAA,gCAAgC,GAAG;IAC9C,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG;CACjC,CAAC;AAMF,SAAgB,yBAAyB,CACvC,QAAqC,EACrC,UAA2B,EAC3B,iBAAiC,EACjC,SAAiC;;IAFjC,2BAAA,EAAA,cAA2B;IAC3B,kCAAA,EAAA,yBAAiC;IACjC,0BAAA,EA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AAE,KAAK;SAChB;QACD;YACE,MAAM,EAAE,MAAA,QAAQ,CAAC,aAAa,mCAAI,IAAI,CAAC,aAAa,CAAC,SAAS;YAC9D,UAAU,EAAE,KAAK;YACjB,QAAQ,EAAE,KAAK;SAChB;KACF,CAAC;IAEF,OAAO,IAAI,IAAI,CAAC,sBAAsB,CAAC;QACrC,SAAS,WAAA;QACT,IAAI,MAAA;QACJ,IAAI,MAAA;KACL,CAAC,CAAC;AACL,CAAC;AArED,8DAqEC"}

+ 23 - 0
clients/bolt-sdk/lib/delegation/undelegate.d.ts

@@ -0,0 +1,23 @@
+import * as beet from "@metaplex-foundation/beet";
+import * as web3 from "@solana/web3.js";
+export declare const undelegateStruct: beet.FixableBeetArgsStruct<{
+  instructionDiscriminator: number[];
+}>;
+export interface UndelegateInstructionAccounts {
+  payer: web3.PublicKey;
+  delegatedAccount: web3.PublicKey;
+  ownerProgram: web3.PublicKey;
+  buffer?: web3.PublicKey;
+  commitStatePda?: web3.PublicKey;
+  commitStateRecordPda?: web3.PublicKey;
+  delegationRecord?: web3.PublicKey;
+  delegateAccountSeeds?: web3.PublicKey;
+  reimbursement: web3.PublicKey;
+  systemProgram?: web3.PublicKey;
+}
+export declare const undelegateInstructionDiscriminator: number[];
+export declare function createUndelegateInstruction(
+  accounts: UndelegateInstructionAccounts,
+  programId?: web3.PublicKey
+): web3.TransactionInstruction;
+//# sourceMappingURL=undelegate.d.ts.map

+ 1 - 0
clients/bolt-sdk/lib/delegation/undelegate.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"undelegate.d.ts","sourceRoot":"","sources":["../../src/generated/delegation/undelegate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,2BAA2B,CAAC;AAClD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAIxC,eAAO,MAAM,gBAAgB;8BACD,MAAM,EAAE;EAInC,CAAC;AAMF,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC;IACtB,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC;IACjC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC;IAC7B,MAAM,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IACxB,cAAc,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IAChC,oBAAoB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IACtC,gBAAgB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IAClC,oBAAoB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IACtC,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC;IAC9B,aAAa,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;CAChC;AAED,eAAO,MAAM,kCAAkC,UAA2B,CAAC;AAO3E,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,6BAA6B,EACvC,SAAS,iBAAuC,+BA4EjD"}

+ 152 - 0
clients/bolt-sdk/lib/delegation/undelegate.js

@@ -0,0 +1,152 @@
+"use strict";
+var __createBinding =
+  (this && this.__createBinding) ||
+  (Object.create
+    ? function (o, m, k, k2) {
+        if (k2 === undefined) k2 = k;
+        var desc = Object.getOwnPropertyDescriptor(m, k);
+        if (
+          !desc ||
+          ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
+        ) {
+          desc = {
+            enumerable: true,
+            get: function () {
+              return m[k];
+            },
+          };
+        }
+        Object.defineProperty(o, k2, desc);
+      }
+    : function (o, m, k, k2) {
+        if (k2 === undefined) k2 = k;
+        o[k2] = m[k];
+      });
+var __setModuleDefault =
+  (this && this.__setModuleDefault) ||
+  (Object.create
+    ? function (o, v) {
+        Object.defineProperty(o, "default", { enumerable: true, value: v });
+      }
+    : function (o, v) {
+        o["default"] = v;
+      });
+var __importStar =
+  (this && this.__importStar) ||
+  function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null)
+      for (var k in mod)
+        if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
+          __createBinding(result, mod, k);
+    __setModuleDefault(result, mod);
+    return result;
+  };
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.createUndelegateInstruction =
+  exports.undelegateInstructionDiscriminator =
+  exports.undelegateStruct =
+    void 0;
+var beet = __importStar(require("@metaplex-foundation/beet"));
+var web3 = __importStar(require("@solana/web3.js"));
+var accounts_1 = require("./accounts");
+var web3_js_1 = require("@solana/web3.js");
+exports.undelegateStruct = new beet.FixableBeetArgsStruct(
+  [["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)]],
+  "UndelegateInstructionArgs"
+);
+exports.undelegateInstructionDiscriminator = [3, 0, 0, 0, 0, 0, 0, 0];
+function createUndelegateInstruction(accounts, programId) {
+  var _a, _b, _c, _d, _e, _f;
+  if (programId === void 0) {
+    programId = new web3_js_1.PublicKey(accounts_1.DELEGATION_PROGRAM_ID);
+  }
+  var data = exports.undelegateStruct.serialize({
+    instructionDiscriminator: exports.undelegateInstructionDiscriminator,
+  })[0];
+  var _g = (0, accounts_1.getDelegationAccounts)(
+      accounts.delegatedAccount,
+      accounts.ownerProgram,
+      false
+    ),
+    delegationPda = _g.delegationPda,
+    delegatedAccountSeedsPda = _g.delegatedAccountSeedsPda,
+    bufferPda = _g.bufferPda,
+    commitStateRecordPda = _g.commitStateRecordPda,
+    commitStatePda = _g.commitStatePda;
+  var keys = [
+    {
+      pubkey: accounts.payer,
+      isWritable: false,
+      isSigner: true,
+    },
+    {
+      pubkey: accounts.delegatedAccount,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey: accounts.ownerProgram,
+      isWritable: false,
+      isSigner: false,
+    },
+    {
+      pubkey: (_a = accounts.buffer) !== null && _a !== void 0 ? _a : bufferPda,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey:
+        (_b = accounts.commitStatePda) !== null && _b !== void 0
+          ? _b
+          : commitStatePda,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey:
+        (_c = accounts.commitStateRecordPda) !== null && _c !== void 0
+          ? _c
+          : commitStateRecordPda,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey:
+        (_d = accounts.delegationRecord) !== null && _d !== void 0
+          ? _d
+          : delegationPda,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey:
+        (_e = accounts.delegateAccountSeeds) !== null && _e !== void 0
+          ? _e
+          : delegatedAccountSeedsPda,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey: accounts.reimbursement,
+      isWritable: false,
+      isSigner: false,
+    },
+    {
+      pubkey:
+        (_f = accounts.systemProgram) !== null && _f !== void 0
+          ? _f
+          : web3.SystemProgram.programId,
+      isWritable: false,
+      isSigner: false,
+    },
+  ];
+  return new web3.TransactionInstruction({
+    programId: programId,
+    keys: keys,
+    data: data,
+  });
+}
+exports.createUndelegateInstruction = createUndelegateInstruction;
+//# sourceMappingURL=undelegate.js.map

+ 1 - 0
clients/bolt-sdk/lib/delegation/undelegate.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"undelegate.js","sourceRoot":"","sources":["../../src/generated/delegation/undelegate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAkD;AAClD,oDAAwC;AACxC,uCAA0E;AAC1E,2CAA4C;AAE/B,QAAA,gBAAgB,GAAG,IAAI,IAAI,CAAC,qBAAqB,CAG5D,CAAC,CAAC,0BAA0B,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EACtE,2BAA2B,CAC5B,CAAC;AAmBW,QAAA,kCAAkC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAO3E,SAAgB,2BAA2B,CACzC,QAAuC,EACvC,SAAgD;;IAAhD,0BAAA,EAAA,gBAAgB,mBAAS,CAAC,gCAAqB,CAAC;IAEzC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E,QAAQ,CAAC,aAAa;YAC9B,UAAU,EAAE,KAAK;YACjB,QAAQ,EAAE,KAAK;SAChB;QACD;YACE,MAAM,EAAE,MAAA,QAAQ,CAAC,aAAa,mCAAI,IAAI,CAAC,aAAa,CAAC,SAAS;YAC9D,UAAU,EAAE,KAAK;YACjB,QAAQ,EAAE,KAAK;SAChB;KACF,CAAC;IAEF,OAAO,IAAI,IAAI,CAAC,sBAAsB,CAAC;QACrC,SAAS,WAAA;QACT,IAAI,MAAA;QACJ,IAAI,MAAA;KACL,CAAC,CAAC;AACL,CAAC;AA9ED,kEA8EC"}

+ 2 - 0
clients/bolt-sdk/lib/index.d.ts

@@ -4,6 +4,8 @@ import BN from "bn.js";
 export * from "./accounts";
 export * from "./accounts";
 export * from "./instructions";
 export * from "./instructions";
 export * from "./transactions/transactions";
 export * from "./transactions/transactions";
+export * from "./delegation/accounts";
+export * from "./delegation/delegate";
 export declare const PROGRAM_ADDRESS =
 export declare const PROGRAM_ADDRESS =
   "WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n";
   "WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n";
 export declare const SYSVAR_INSTRUCTIONS_PUBKEY: PublicKey;
 export declare const SYSVAR_INSTRUCTIONS_PUBKEY: PublicKey;

+ 1 - 1
clients/bolt-sdk/lib/index.d.ts.map

@@ -1 +1 @@
-{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/generated/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,MAAM,OAAO,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAQ5C,eAAO,MAAM,eAAe,gDAAgD,CAAC;AAE7E,eAAO,MAAM,0BAA0B,WAEtC,CAAC;AAQF,eAAO,MAAM,UAAU,WAAiC,CAAC;AAEzD,wBAAgB,oB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AAU,EAC3C,SAAS,CAAC,EAAE,MAAM,EAClB,SAAS,GAAE,SAAqC,aAcjD;AAED,wBAAgB,gBAAgB,CAC9B,kBAAkB,EAAE,SAAS,EAC7B,MAAM,EAAE,SAAS,EACjB,WAAW,GAAE,MAAW,aAMzB;AAcD,wBAAgB,aAAa,CAAC,IAAI,GAAE,GAAQ,UAS3C"}

+ 2 - 0
clients/bolt-sdk/lib/index.js

@@ -49,6 +49,8 @@ var bn_js_1 = __importDefault(require("bn.js"));
 __exportStar(require("./accounts"), exports);
 __exportStar(require("./accounts"), exports);
 __exportStar(require("./instructions"), exports);
 __exportStar(require("./instructions"), exports);
 __exportStar(require("./transactions/transactions"), exports);
 __exportStar(require("./transactions/transactions"), exports);
+__exportStar(require("./delegation/accounts"), exports);
+__exportStar(require("./delegation/delegate"), exports);
 exports.PROGRAM_ADDRESS = "WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n";
 exports.PROGRAM_ADDRESS = "WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n";
 exports.SYSVAR_INSTRUCTIONS_PUBKEY = new web3_js_1.PublicKey(
 exports.SYSVAR_INSTRUCTIONS_PUBKEY = new web3_js_1.PublicKey(
   "Sysvar1nstructions1111111111111111111111111"
   "Sysvar1nstructions1111111111111111111111111"

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
clients/bolt-sdk/lib/index.js.map


+ 51 - 0
clients/bolt-sdk/src/generated/delegation/accounts.ts

@@ -0,0 +1,51 @@
+import { PublicKey } from "@solana/web3.js";
+
+const SEED_BUFFER_PDA = "buffer";
+const SEED_DELEGATION_PDA = "delegation";
+const DELEGATED_ACCOUNT_SEEDS = "account-seeds";
+const SEED_COMMIT_STATE_RECORD_PDA = "commit-state-record";
+const SEED_STATE_DIFF_PDA = "state-diff";
+export const DELEGATION_PROGRAM_ID =
+  "DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh";
+
+export function getDelegationAccounts(
+  accountToDelegate: PublicKey,
+  ownerProgram: PublicKey,
+  ownedBuffer: boolean = true
+) {
+  const pdaBytes = accountToDelegate.toBytes();
+
+  const [delegationPda] = PublicKey.findProgramAddressSync(
+    [Buffer.from(SEED_DELEGATION_PDA), pdaBytes],
+    new PublicKey(DELEGATION_PROGRAM_ID)
+  );
+
+  const [delegatedAccountSeedsPda] = PublicKey.findProgramAddressSync(
+    [Buffer.from(DELEGATED_ACCOUNT_SEEDS), pdaBytes],
+    new PublicKey(DELEGATION_PROGRAM_ID)
+  );
+
+  const [bufferPda] = PublicKey.findProgramAddressSync(
+    [Buffer.from(SEED_BUFFER_PDA), pdaBytes],
+    ownedBuffer
+      ? new PublicKey(ownerProgram)
+      : new PublicKey(DELEGATION_PROGRAM_ID)
+  );
+
+  const [commitStateRecordPda] = PublicKey.findProgramAddressSync(
+    [Buffer.from(SEED_COMMIT_STATE_RECORD_PDA), pdaBytes],
+    new PublicKey(DELEGATION_PROGRAM_ID)
+  );
+
+  const [commitStatePda] = PublicKey.findProgramAddressSync(
+    [Buffer.from(SEED_STATE_DIFF_PDA), pdaBytes],
+    new PublicKey(DELEGATION_PROGRAM_ID)
+  );
+  return {
+    delegationPda,
+    delegatedAccountSeedsPda,
+    bufferPda,
+    commitStateRecordPda,
+    commitStatePda,
+  };
+}

+ 117 - 0
clients/bolt-sdk/src/generated/delegation/delegate.ts

@@ -0,0 +1,117 @@
+import * as beet from "@metaplex-foundation/beet";
+import * as web3 from "@solana/web3.js";
+import { DELEGATION_PROGRAM_ID, getDelegationAccounts } from "./accounts";
+
+export interface DelegateInstructionArgs {
+  validUntil: beet.bignum;
+  commitFrequencyMs: number;
+}
+
+export const delegateStruct = new beet.FixableBeetArgsStruct<
+  DelegateInstructionArgs & {
+    instructionDiscriminator: number[] /* size: 8 */;
+  }
+>(
+  [
+    ["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)],
+    ["validUntil", beet.i64],
+    ["commitFrequencyMs", beet.u32],
+  ],
+  "DelegateInstructionArgs"
+);
+
+/**
+ * Accounts required by the _delegate_ instruction
+ *
+ */
+
+export interface DelegateInstructionAccounts {
+  payer: web3.PublicKey;
+  entity: web3.PublicKey;
+  account: web3.PublicKey;
+  ownerProgram: web3.PublicKey;
+  buffer?: web3.PublicKey;
+  delegationRecord?: web3.PublicKey;
+  delegateAccountSeeds?: web3.PublicKey;
+  delegationProgram?: web3.PublicKey;
+  systemProgram?: web3.PublicKey;
+}
+
+export const delegateInstructionDiscriminator = [
+  90, 147, 75, 178, 85, 88, 4, 137,
+];
+
+/**
+ * Creates a Delegate instruction.
+ */
+
+export function createDelegateInstruction(
+  accounts: DelegateInstructionAccounts,
+  validUntil: beet.bignum = 0,
+  commitFrequencyMs: number = 30000,
+  programId = accounts.ownerProgram
+) {
+  const [data] = delegateStruct.serialize({
+    instructionDiscriminator: delegateInstructionDiscriminator,
+    validUntil,
+    commitFrequencyMs,
+  });
+
+  const { delegationPda, delegatedAccountSeedsPda, bufferPda } =
+    getDelegationAccounts(accounts.account, accounts.ownerProgram);
+
+  const keys: web3.AccountMeta[] = [
+    {
+      pubkey: accounts.payer,
+      isWritable: false,
+      isSigner: true,
+    },
+    {
+      pubkey: accounts.entity,
+      isWritable: false,
+      isSigner: false,
+    },
+    {
+      pubkey: accounts.account,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey: accounts.ownerProgram,
+      isWritable: false,
+      isSigner: false,
+    },
+    {
+      pubkey: accounts.buffer ?? bufferPda,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey: accounts.delegationRecord ?? delegationPda,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey: accounts.delegateAccountSeeds ?? delegatedAccountSeedsPda,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey:
+        accounts.delegationProgram ?? new web3.PublicKey(DELEGATION_PROGRAM_ID),
+      isWritable: false,
+      isSigner: false,
+    },
+    {
+      pubkey: accounts.systemProgram ?? web3.SystemProgram.programId,
+      isWritable: false,
+      isSigner: false,
+    },
+  ];
+
+  return new web3.TransactionInstruction({
+    programId,
+    keys,
+    data,
+  });
+}

+ 115 - 0
clients/bolt-sdk/src/generated/delegation/undelegate.ts

@@ -0,0 +1,115 @@
+import * as beet from "@metaplex-foundation/beet";
+import * as web3 from "@solana/web3.js";
+import { DELEGATION_PROGRAM_ID, getDelegationAccounts } from "./accounts";
+import { PublicKey } from "@solana/web3.js";
+
+export const undelegateStruct = new beet.FixableBeetArgsStruct<{
+  instructionDiscriminator: number[];
+}>(
+  [["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)]],
+  "UndelegateInstructionArgs"
+);
+
+/**
+ * Accounts required by the _undelegate_ instruction
+ */
+
+export interface UndelegateInstructionAccounts {
+  payer: web3.PublicKey;
+  delegatedAccount: web3.PublicKey;
+  ownerProgram: web3.PublicKey;
+  buffer?: web3.PublicKey;
+  commitStatePda?: web3.PublicKey;
+  commitStateRecordPda?: web3.PublicKey;
+  delegationRecord?: web3.PublicKey;
+  delegateAccountSeeds?: web3.PublicKey;
+  reimbursement: web3.PublicKey;
+  systemProgram?: web3.PublicKey;
+}
+
+export const undelegateInstructionDiscriminator = [3, 0, 0, 0, 0, 0, 0, 0];
+
+/**
+ * Creates an _undelegate_ instruction.
+ *
+ */
+
+export function createUndelegateInstruction(
+  accounts: UndelegateInstructionAccounts,
+  programId = new PublicKey(DELEGATION_PROGRAM_ID)
+) {
+  const [data] = undelegateStruct.serialize({
+    instructionDiscriminator: undelegateInstructionDiscriminator,
+  });
+
+  const {
+    delegationPda,
+    delegatedAccountSeedsPda,
+    bufferPda,
+    commitStateRecordPda,
+    commitStatePda,
+  } = getDelegationAccounts(
+    accounts.delegatedAccount,
+    accounts.ownerProgram,
+    false
+  );
+
+  const keys: web3.AccountMeta[] = [
+    {
+      pubkey: accounts.payer,
+      isWritable: false,
+      isSigner: true,
+    },
+    {
+      pubkey: accounts.delegatedAccount,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey: accounts.ownerProgram,
+      isWritable: false,
+      isSigner: false,
+    },
+    {
+      pubkey: accounts.buffer ?? bufferPda,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey: accounts.commitStatePda ?? commitStatePda,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey: accounts.commitStateRecordPda ?? commitStateRecordPda,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey: accounts.delegationRecord ?? delegationPda,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey: accounts.delegateAccountSeeds ?? delegatedAccountSeedsPda,
+      isWritable: true,
+      isSigner: false,
+    },
+    {
+      pubkey: accounts.reimbursement,
+      isWritable: false,
+      isSigner: false,
+    },
+    {
+      pubkey: accounts.systemProgram ?? web3.SystemProgram.programId,
+      isWritable: false,
+      isSigner: false,
+    },
+  ];
+
+  return new web3.TransactionInstruction({
+    programId,
+    keys,
+    data,
+  });
+}

+ 2 - 0
clients/bolt-sdk/src/generated/index.ts

@@ -3,6 +3,8 @@ import BN from "bn.js";
 export * from "./accounts";
 export * from "./accounts";
 export * from "./instructions";
 export * from "./instructions";
 export * from "./transactions/transactions";
 export * from "./transactions/transactions";
+export * from "./delegation/accounts";
+export * from "./delegation/delegate";
 
 
 /**
 /**
  * Program address
  * Program address

+ 4 - 0
crates/bolt-lang/Cargo.toml

@@ -13,6 +13,7 @@ anchor-lang = { workspace = true }
 
 
 # Bolt Attributes
 # Bolt Attributes
 bolt-attribute-bolt-program = { workspace = true }
 bolt-attribute-bolt-program = { workspace = true }
+bolt-attribute-bolt-delegate = { workspace = true }
 bolt-attribute-bolt-component = { workspace = true }
 bolt-attribute-bolt-component = { workspace = true }
 bolt-attribute-bolt-system = { workspace = true }
 bolt-attribute-bolt-system = { workspace = true }
 bolt-attribute-bolt-system-input = { workspace = true }
 bolt-attribute-bolt-system-input = { workspace = true }
@@ -25,6 +26,9 @@ bolt-attribute-bolt-arguments = { workspace = true }
 world = { workspace = true }
 world = { workspace = true }
 bolt-system = { workspace = true }
 bolt-system = { workspace = true }
 
 
+# Delegation
+delegation-program-sdk = { workspace = true }
+
 # Other dependencies
 # Other dependencies
 serde = { workspace = true }
 serde = { workspace = true }
 serde_json = {workspace = true }
 serde_json = {workspace = true }

+ 1 - 1
crates/bolt-lang/attribute/bolt-program/src/lib.rs

@@ -18,7 +18,7 @@ use syn::{
 ///     use super::*;
 ///     use super::*;
 /// }
 /// }
 ///
 ///
-/// #[account]
+///
 /// #[component]
 /// #[component]
 /// pub struct Position {
 /// pub struct Position {
 ///     pub x: i64,
 ///     pub x: i64,

+ 61 - 30
crates/bolt-lang/attribute/component/src/lib.rs

@@ -1,7 +1,10 @@
 use proc_macro::TokenStream;
 use proc_macro::TokenStream;
 
 
 use quote::quote;
 use quote::quote;
-use syn::{parse_macro_input, parse_quote, Attribute, DeriveInput, Lit, Meta, NestedMeta};
+use syn::{
+    parse_macro_input, parse_quote, Attribute, DeriveInput, Lit, Meta, MetaList, MetaNameValue,
+    NestedMeta,
+};
 
 
 use bolt_utils::add_bolt_metadata;
 use bolt_utils::add_bolt_metadata;
 
 
@@ -10,8 +13,8 @@ use bolt_utils::add_bolt_metadata;
 /// The component_id can be used to define the seed used to generate the PDA which stores the component data.
 /// The component_id can be used to define the seed used to generate the PDA which stores the component data.
 /// The macro also adds the InitSpace and Default derives to the struct.
 /// The macro also adds the InitSpace and Default derives to the struct.
 ///
 ///
-/// #[component_deserialize]
-/// #[derive(Clone)]
+/// #[component]
+/// #[derive(Default, Copy)]
 /// pub struct Position {
 /// pub struct Position {
 ///     pub x: i64,
 ///     pub x: i64,
 ///     pub y: i64,
 ///     pub y: i64,
@@ -22,35 +25,20 @@ use bolt_utils::add_bolt_metadata;
 pub fn component(attr: TokenStream, item: TokenStream) -> TokenStream {
 pub fn component(attr: TokenStream, item: TokenStream) -> TokenStream {
     let mut input = parse_macro_input!(item as DeriveInput);
     let mut input = parse_macro_input!(item as DeriveInput);
     let mut component_id_value = None;
     let mut component_id_value = None;
+    let mut delegate_set = false;
 
 
     if !attr.is_empty() {
     if !attr.is_empty() {
         let attr_meta = parse_macro_input!(attr as Meta);
         let attr_meta = parse_macro_input!(attr as Meta);
-
+        delegate_set = is_delegate_set(&attr_meta);
         component_id_value = match attr_meta {
         component_id_value = match attr_meta {
             Meta::Path(_) => None,
             Meta::Path(_) => None,
-            Meta::NameValue(meta_name_value) if meta_name_value.path.is_ident("component_id") => {
-                if let Lit::Str(lit) = meta_name_value.lit {
-                    Some(lit.value())
-                } else {
-                    None
+            Meta::NameValue(meta_name_value) => extract_component_id(&meta_name_value),
+            Meta::List(meta_list) => {
+                if !delegate_set {
+                    delegate_set = is_delegate_set(&Meta::List(meta_list.clone()));
                 }
                 }
+                find_component_id_in_list(meta_list)
             }
             }
-            Meta::List(meta) => meta.nested.into_iter().find_map(|nested_meta| {
-                if let NestedMeta::Meta(Meta::NameValue(meta_name_value)) = nested_meta {
-                    if meta_name_value.path.is_ident("component_id") {
-                        if let Lit::Str(lit) = meta_name_value.lit {
-                            Some(lit.value())
-                        } else {
-                            None
-                        }
-                    } else {
-                        None
-                    }
-                } else {
-                    None
-                }
-            }),
-            _ => None,
         };
         };
     }
     }
 
 
@@ -67,15 +55,25 @@ pub fn component(attr: TokenStream, item: TokenStream) -> TokenStream {
     let name = &input.ident;
     let name = &input.ident;
     let component_name = syn::Ident::new(&name.to_string().to_lowercase(), input.ident.span());
     let component_name = syn::Ident::new(&name.to_string().to_lowercase(), input.ident.span());
 
 
-    let anchor_program = quote! {
-        #[bolt_program(#name)]
-        pub mod #component_name {
-            use super::*;
+    let bolt_program = if delegate_set {
+        quote! {
+            #[delegate(#name)]
+            #[bolt_program(#name)]
+            pub mod #component_name {
+                use super::*;
+            }
+        }
+    } else {
+        quote! {
+            #[bolt_program(#name)]
+            pub mod #component_name {
+                use super::*;
+            }
         }
         }
     };
     };
 
 
     let expanded = quote! {
     let expanded = quote! {
-        #anchor_program
+        #bolt_program
 
 
         #additional_macro
         #additional_macro
         #input
         #input
@@ -138,3 +136,36 @@ fn define_new_fn(input: &DeriveInput) -> proc_macro2::TokenStream {
     }
     }
     quote! {}
     quote! {}
 }
 }
+
+fn is_delegate_set(meta: &Meta) -> bool {
+    match meta {
+        Meta::Path(path) => path.is_ident("delegate"),
+        Meta::List(meta_list) => meta_list.nested.iter().any(|nested_meta| {
+            if let NestedMeta::Meta(Meta::Path(path)) = nested_meta {
+                path.is_ident("delegate")
+            } else {
+                false
+            }
+        }),
+        _ => false,
+    }
+}
+
+fn extract_component_id(meta_name_value: &MetaNameValue) -> Option<String> {
+    if meta_name_value.path.is_ident("component_id") {
+        if let Lit::Str(lit) = &meta_name_value.lit {
+            return Some(lit.value());
+        }
+    }
+    None
+}
+
+fn find_component_id_in_list(meta_list: MetaList) -> Option<String> {
+    meta_list.nested.into_iter().find_map(|nested_meta| {
+        if let NestedMeta::Meta(Meta::NameValue(meta_name_value)) = nested_meta {
+            extract_component_id(&meta_name_value)
+        } else {
+            None
+        }
+    })
+}

+ 17 - 0
crates/bolt-lang/attribute/delegate/Cargo.toml

@@ -0,0 +1,17 @@
+[package]
+name = "bolt-attribute-bolt-delegate"
+description = "Bolt attribute-bolt-delegate"
+version = { workspace = true }
+authors = { workspace = true }
+repository = { workspace = true }
+homepage = { workspace = true }
+license = { workspace = true }
+edition = { workspace = true }
+
+[lib]
+proc-macro = true
+
+[dependencies]
+syn = { workspace = true }
+quote = { workspace = true }
+proc-macro2 = { workspace = true }

+ 176 - 0
crates/bolt-lang/attribute/delegate/src/lib.rs

@@ -0,0 +1,176 @@
+use proc_macro::TokenStream;
+
+use proc_macro2::TokenStream as TokenStream2;
+use quote::quote;
+use syn::{parse_macro_input, AttributeArgs, ItemMod, NestedMeta, Type};
+
+/// This macro attribute is used to inject instructions and struct needed to delegate BOLT component.
+///
+/// Components can be delegate in order to be updated in an Ephemeral Rollup
+///
+/// # Example
+/// ```ignore
+///
+/// #[component(delegate)]
+/// pub struct Position {
+///     pub x: i64,
+///     pub y: i64,
+///     pub z: i64,
+/// }
+/// ```
+#[proc_macro_attribute]
+pub fn delegate(args: TokenStream, input: TokenStream) -> TokenStream {
+    let ast = parse_macro_input!(input as syn::ItemMod);
+    let args = parse_macro_input!(args as syn::AttributeArgs);
+    let component_type =
+        extract_type_name(&args).expect("Expected a component type in macro arguments");
+    let modified = modify_component_module(ast, &component_type);
+    TokenStream::from(quote! {
+        #modified
+    })
+}
+
+/// Modifies the component module and adds the necessary functions and structs.
+fn modify_component_module(mut module: ItemMod, component_type: &Type) -> ItemMod {
+    let (delegate_fn, delegate_struct) = generate_delegate(component_type);
+    let (undelegate_fn, undelegate_struct) = generate_undelegate();
+    module.content = module.content.map(|(brace, mut items)| {
+        items.extend(
+            vec![
+                delegate_fn,
+                delegate_struct,
+                undelegate_fn,
+                undelegate_struct,
+            ]
+            .into_iter()
+            .map(|item| syn::parse2(item).unwrap())
+            .collect::<Vec<_>>(),
+        );
+        (brace, items)
+    });
+    module
+}
+
+/// Generates the undelegate function and struct.
+fn generate_undelegate() -> (TokenStream2, TokenStream2) {
+    (
+        quote! {
+            #[automatically_derived]
+            pub fn process_undelegation(ctx: Context<InitializeAfterUndelegation>, account_seeds: Vec<Vec<u8>>) -> Result<()> {
+                let [delegated_account, buffer, payer, system_program] = [
+                    &ctx.accounts.base_account,
+                    &ctx.accounts.buffer,
+                    &ctx.accounts.payer,
+                    &ctx.accounts.system_program,
+                ];
+                undelegate_account(
+                    delegated_account,
+                    &id(),
+                    buffer,
+                    payer,
+                    system_program,
+                    account_seeds,
+                )?;
+                Ok(())
+            }
+        },
+        quote! {
+            #[automatically_derived]
+            #[derive(Accounts)]
+                pub struct InitializeAfterUndelegation<'info> {
+                /// CHECK:`
+                #[account(mut)]
+                pub base_account: AccountInfo<'info>,
+                /// CHECK:`
+                #[account()]
+                pub buffer: AccountInfo<'info>,
+                /// CHECK:
+                #[account(mut)]
+                pub payer: AccountInfo<'info>,
+                /// CHECK:
+                pub system_program: AccountInfo<'info>,
+            }
+        },
+    )
+}
+
+/// Generates the delegate instruction and related structs to inject in the component.
+fn generate_delegate(component_type: &Type) -> (TokenStream2, TokenStream2) {
+    (
+        quote! {
+            #[automatically_derived]
+            pub fn delegate(ctx: Context<DelegateInput>, valid_until: i64, commit_frequency_ms: u32) -> Result<()> {
+
+                let [payer, entity, account, owner_program, buffer, delegation_record, delegate_account_seeds, delegation_program, system_program] = [
+                    &ctx.accounts.payer,
+                    &ctx.accounts.entity.to_account_info(),
+                    &ctx.accounts.account,
+                    &ctx.accounts.owner_program,
+                    &ctx.accounts.buffer,
+                    &ctx.accounts.delegation_record,
+                    &ctx.accounts.delegate_account_seeds,
+                    &ctx.accounts.delegation_program,
+                    &ctx.accounts.system_program,
+                ];
+
+                let pda_seeds: &[&[u8]] = &[<#component_type>::seed(), &entity.key.to_bytes()];
+
+                delegate_account(
+                    payer,
+                    account,
+                    owner_program,
+                    buffer,
+                    delegation_record,
+                    delegate_account_seeds,
+                    delegation_program,
+                    system_program,
+                    pda_seeds,
+                    valid_until,
+                    commit_frequency_ms,
+                )?;
+                Ok(())
+            }
+        },
+        quote! {
+            #[automatically_derived]
+            #[derive(Accounts)]
+            pub struct DelegateInput<'info> {
+                pub payer: Signer<'info>,
+                #[account()]
+                pub entity: Account<'info, Entity>,
+                /// CHECK:
+                #[account(mut)]
+                pub account: AccountInfo<'info>,
+                /// CHECK:`
+                pub owner_program: AccountInfo<'info>,
+                /// CHECK:
+                #[account(mut)]
+                pub buffer: AccountInfo<'info>,
+                /// CHECK:`
+                #[account(mut)]
+                pub delegation_record: AccountInfo<'info>,
+                /// CHECK:`
+                #[account(mut)]
+                pub delegate_account_seeds: AccountInfo<'info>,
+                /// CHECK:`
+                pub delegation_program: AccountInfo<'info>,
+                /// CHECK:`
+                pub system_program: AccountInfo<'info>,
+            }
+        },
+    )
+}
+
+/// Extracts the type name from attribute arguments.
+fn extract_type_name(args: &AttributeArgs) -> Option<Type> {
+    args.iter().find_map(|arg| {
+        if let NestedMeta::Meta(syn::Meta::Path(path)) = arg {
+            Some(Type::Path(syn::TypePath {
+                qself: None,
+                path: path.clone(),
+            }))
+        } else {
+            None
+        }
+    })
+}

+ 3 - 0
crates/bolt-lang/src/lib.rs

@@ -8,6 +8,7 @@ pub use bolt_attribute_bolt_arguments::arguments;
 pub use bolt_attribute_bolt_component::component;
 pub use bolt_attribute_bolt_component::component;
 pub use bolt_attribute_bolt_component_deserialize::component_deserialize;
 pub use bolt_attribute_bolt_component_deserialize::component_deserialize;
 pub use bolt_attribute_bolt_component_id::component_id;
 pub use bolt_attribute_bolt_component_id::component_id;
+pub use bolt_attribute_bolt_delegate::delegate;
 pub use bolt_attribute_bolt_extra_accounts::extra_accounts;
 pub use bolt_attribute_bolt_extra_accounts::extra_accounts;
 pub use bolt_attribute_bolt_extra_accounts::pubkey;
 pub use bolt_attribute_bolt_extra_accounts::pubkey;
 pub use bolt_attribute_bolt_program::bolt_program;
 pub use bolt_attribute_bolt_program::bolt_program;
@@ -19,6 +20,8 @@ pub use world;
 pub use world::program::World;
 pub use world::program::World;
 pub use world::Entity;
 pub use world::Entity;
 
 
+pub use delegation_program_sdk::{delegate_account, undelegate_account};
+
 pub use serde;
 pub use serde;
 
 
 use std::str;
 use std::str;

+ 1 - 1
examples/component-position/src/lib.rs

@@ -2,7 +2,7 @@ use bolt_lang::*;
 
 
 declare_id!("Fn1JzzEdyb55fsyduWS94mYHizGhJZuhvjX6DVvrmGbQ");
 declare_id!("Fn1JzzEdyb55fsyduWS94mYHizGhJZuhvjX6DVvrmGbQ");
 
 
-#[component]
+#[component(delegate)]
 #[derive(Copy, Default)]
 #[derive(Copy, Default)]
 pub struct Position {
 pub struct Position {
     pub x: i64,
     pub x: i64,

+ 37 - 1
tests/bolt.ts

@@ -11,13 +11,16 @@ import { type World } from "../target/types/world";
 import { expect } from "chai";
 import { expect } from "chai";
 import BN from "bn.js";
 import BN from "bn.js";
 import {
 import {
+  createDelegateInstruction,
   createInitializeRegistryInstruction,
   createInitializeRegistryInstruction,
+  DELEGATION_PROGRAM_ID,
   FindComponentPda,
   FindComponentPda,
   FindEntityPda,
   FindEntityPda,
   FindWorldPda,
   FindWorldPda,
   FindWorldRegistryPda,
   FindWorldRegistryPda,
   SYSVAR_INSTRUCTIONS_PUBKEY,
   SYSVAR_INSTRUCTIONS_PUBKEY,
 } from "../clients/bolt-sdk";
 } from "../clients/bolt-sdk";
+import { createUndelegateInstruction } from "../clients/bolt-sdk/lib/delegation/undelegate";
 
 
 enum Direction {
 enum Direction {
   Left = "Left",
   Left = "Left",
@@ -81,7 +84,7 @@ describe("bolt", () => {
     const registryPda = FindWorldRegistryPda(worldProgram.programId);
     const registryPda = FindWorldRegistryPda(worldProgram.programId);
 
 
     const worldPda = FindWorldPda(new BN(0), worldProgram.programId);
     const worldPda = FindWorldPda(new BN(0), worldProgram.programId);
-    await worldProgram.methods
+    const res = await worldProgram.methods
       .initializeNewWorld()
       .initializeNewWorld()
       .accounts({
       .accounts({
         world: worldPda,
         world: worldPda,
@@ -89,6 +92,7 @@ describe("bolt", () => {
         payer: provider.wallet.publicKey,
         payer: provider.wallet.publicKey,
       })
       })
       .rpc();
       .rpc();
+    console.log(res);
   });
   });
 
 
   it("InitializeNewWorld 2", async () => {
   it("InitializeNewWorld 2", async () => {
@@ -636,4 +640,36 @@ describe("bolt", () => {
     }
     }
     expect(invalid).to.equal(true);
     expect(invalid).to.equal(true);
   });
   });
+
+  // Check component delegation
+  it("Check component delegation", async () => {
+    const delegateIx = createDelegateInstruction({
+      entity: entity1,
+      account: componentPositionEntity1,
+      ownerProgram: boltComponentPositionProgram.programId,
+      payer: provider.wallet.publicKey,
+    });
+    const tx = new anchor.web3.Transaction().add(delegateIx);
+    await provider.sendAndConfirm(tx, [], { skipPreflight: true });
+    const acc = await provider.connection.getAccountInfo(
+      componentPositionEntity1
+    );
+    expect(acc.owner.toString()).to.equal(DELEGATION_PROGRAM_ID);
+  });
+
+  // Check component undelegation
+  it("Check component undelegation", async () => {
+    const delegateIx = createUndelegateInstruction({
+      payer: provider.wallet.publicKey,
+      delegatedAccount: componentPositionEntity1,
+      ownerProgram: boltComponentPositionProgram.programId,
+      reimbursement: provider.wallet.publicKey,
+    });
+    const tx = new anchor.web3.Transaction().add(delegateIx);
+    await provider.sendAndConfirm(tx, [], { skipPreflight: true });
+    const acc = await provider.connection.getAccountInfo(
+      componentPositionEntity1
+    );
+    expect(acc.owner).to.deep.equal(boltComponentPositionProgram.programId);
+  });
 });
 });

+ 14 - 0
tests/fixtures/commit_record.json

@@ -0,0 +1,14 @@
+{
+  "pubkey": "EEmsg7GbxEAw5f9hGfZRmJRJ27HK8KeGDp7ViW9X2mYa",
+  "account": {
+    "lamports": 10000000000,
+    "data": [
+      "ZQAAAAAAAAANIE3M9DimrEJxltpwKm61Yp7ewoJdr2S+aglFnFBgSMG8elN20S317TFLuOUqG2fgfULbw8fsdDYy2lt5hSFQ2CRgZgAAAAA=",
+      "base64"
+    ],
+    "owner": "DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh",
+    "executable": false,
+    "rentEpoch": 18446744073709551615,
+    "space": 80
+  }
+}

+ 14 - 0
tests/fixtures/committed_state.json

@@ -0,0 +1,14 @@
+{
+  "pubkey": "7nQvHcfEqtFmY2q6hiQbidu8BCNdqegnEFfH7HkByFn5",
+  "account": {
+    "lamports": 1000000000000,
+    "data": [
+      "DwAAAAUFBQUFBQUFBQUFBQUFBQ==",
+      "base64"
+    ],
+    "owner": "DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh",
+    "executable": false,
+    "rentEpoch": 18446744073709551615,
+    "space": 19
+  }
+}

BIN
tests/fixtures/delegation.so


Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.