Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WASM Move Calls #1499

Merged
merged 69 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
dbee3d7
Move identity_wasm package into new folder bindings/wasm/identity_wasm
chrisgitiota Dec 4, 2024
5d77eaa
Reorganize tsconfig and typedoc files
chrisgitiota Dec 4, 2024
cdf0129
Extend build scripts to handle multiple artifacts and add new binding…
chrisgitiota Dec 4, 2024
e7cc8eb
Merge branch 'feat/identity-rebased-alpha' into feat/wasm32-develop-a…
chrisgitiota Dec 4, 2024
9a9415a
Update identity_wasm/package.json to use shared build scripts
chrisgitiota Dec 4, 2024
2c21ec7
Initial version of the identity_iota_interaction crate
chrisgitiota Dec 5, 2024
4f9d0d6
Provide identity_iota_interaction crate types as `use identity_iota::…
chrisgitiota Dec 5, 2024
189481e
Initial version of iota_interactions_ts
chrisgitiota Dec 9, 2024
6445ddb
Prepare identity_iota_core/rebased for iota_interaction usage
chrisgitiota Dec 9, 2024
bdc03d3
Merge branch 'feat/identity-rebased-alpha' into feat/wasm32-develop-a…
chrisgitiota Dec 9, 2024
c393acb
Minor README fixes
chrisgitiota Dec 9, 2024
fe8376a
Updated identity_interaction_rust MoveCalls to the latest identity_io…
chrisgitiota Dec 9, 2024
f31eda4
First compilable but not successfully testable version of identity_io…
chrisgitiota Dec 12, 2024
0dfb752
add stubs for `ProgrammableTransaction` type chain
wulfraem Dec 13, 2024
7fea4db
re-add changes from `feat/add-iota_client_ts_sdk-impls` as closely as…
wulfraem Dec 13, 2024
e1c9814
ts move calls
UMR1352 Dec 27, 2024
d8627e5
Merge branch 'feat/identity-rebased-alpha' into feat/wasm32-develop-a…
chrisgitiota Jan 6, 2025
f348ff7
Use cloned native IotaTransactionBlockResponse instead of a BCS deser…
chrisgitiota Jan 7, 2025
c1e4cbf
Fix build warnings and fix MoveType implementation for IotaVerifiable…
chrisgitiota Jan 7, 2025
f46876f
Fix & allow clippy errors
chrisgitiota Jan 7, 2025
f4e7a99
Fix even more clippy errors
chrisgitiota Jan 7, 2025
57968c2
Elide superfluous explicit lifetimes
chrisgitiota Jan 7, 2025
4ed173c
Use rustfmt ignore to exclude identity_iota_interaction/src/sdk_types…
chrisgitiota Jan 8, 2025
1cc7e25
Fix rustfmt issues for identity_iota_core/src/iota_interaction_rust a…
chrisgitiota Jan 8, 2025
59f02b9
Fix rustfmt issues for bindings/wasm/iota_interaction_ts and identity…
chrisgitiota Jan 8, 2025
db8fe86
Update all paths for bindings/wasm/identity_wasm in al GH workflows f…
chrisgitiota Jan 8, 2025
425739a
Rollback removing bindings/wasm/iota_interaction_ts from the workspac…
chrisgitiota Jan 8, 2025
a22dd33
Fix format issue for step "wasm fmt check identity_wasm"
chrisgitiota Jan 8, 2025
59be0ac
Fix issue "identity_iota_core not compilable using --no-default-featu…
chrisgitiota Jan 9, 2025
e43ea51
Remove iota_interaction_ts related steps from github workflows as thi…
chrisgitiota Jan 9, 2025
ffff17f
Fix several dprint issues
chrisgitiota Jan 9, 2025
fb0857f
scratch
UMR1352 Jan 9, 2025
f60f348
Merge remote-tracking branch 'origin/feat/wasm32-develop-alpha' into …
UMR1352 Jan 9, 2025
5dc7ff3
Add iota_interaction_ts build products as 'excludes' to the dprint co…
chrisgitiota Jan 9, 2025
806243e
Fixing paths to the bindings/wasm/identity_wasm crate in several READ…
chrisgitiota Jan 9, 2025
fa94623
fix dprint issue missing empty line at end of file
chrisgitiota Jan 9, 2025
f8e2435
Update licence_template file to allow optional "Modifications", "(c)"…
chrisgitiota Jan 9, 2025
8d993b3
Add missing copyright license comments
chrisgitiota Jan 9, 2025
3c75dc2
Narrowed the dockerignore filter down from "bindings/wasm" to "bindin…
chrisgitiota Jan 9, 2025
e75e6a5
implement TsMoveCalls
UMR1352 Jan 14, 2025
db5ec09
bindings/wasm projects identity_wasm and iota_interaction_ts can be b…
chrisgitiota Jan 14, 2025
59c335a
dprint refomated
chrisgitiota Jan 14, 2025
e413789
assets move calls
UMR1352 Jan 14, 2025
21978e2
Merge branch 'feat/identity-rebased-alpha' into feat/wasm32-develop-a…
chrisgitiota Jan 14, 2025
f1bd28b
avoid unsafe
UMR1352 Jan 15, 2025
8c5a879
clippy
UMR1352 Jan 16, 2025
a1c72de
Removed IntentFn adapters and fixed several issues reulting from last…
chrisgitiota Jan 16, 2025
09e5094
Merge branch 'feat/wasm32-develop-alpha' into feat/ts-move-calls
UMR1352 Jan 16, 2025
b0e0062
Fis issues clippy::needless_as_bytes as the len() directly available …
chrisgitiota Jan 16, 2025
2cd4861
Fis several rustfmt issues
chrisgitiota Jan 16, 2025
d6feacc
Fix even more clippy and rustfmt issues
chrisgitiota Jan 16, 2025
5fe26a3
Update .license_template
chrisgitiota Jan 16, 2025
a9f978c
Fix rustfmt issues in identity_wasm
chrisgitiota Jan 16, 2025
fc360a6
Merge remote-tracking branch 'origin/feat/wasm32-develop-alpha' into …
chrisgitiota Jan 16, 2025
9d5fd35
Fix dprint issues
chrisgitiota Jan 16, 2025
8fd0dd6
Added missing copyright
chrisgitiota Jan 16, 2025
3fe3a33
reactivated 'identity_resolver' dependency for feature iota-client on…
chrisgitiota Jan 17, 2025
ede9a82
Updated "typedoc" and "typedoc-plugin-markdown" npm dependencies and …
chrisgitiota Jan 17, 2025
f19c906
Fixed wrong paths in Readme example code tests configs
chrisgitiota Jan 17, 2025
bf0e64b
implement missing bindings
UMR1352 Jan 17, 2025
e76dba5
make iota_interaction_ts a workspace member again
UMR1352 Jan 17, 2025
10d581d
Merge remote-tracking branch 'origin/feat/wasm32-develop-alpha' into …
UMR1352 Jan 22, 2025
e1beee7
fixes
UMR1352 Jan 22, 2025
9b6bcbd
cargo fmt
UMR1352 Jan 22, 2025
01d85b9
dprint
UMR1352 Jan 22, 2025
e7cc1ff
normalize casing in ts code
UMR1352 Jan 22, 2025
5c0bf24
Merge remote-tracking branch 'origin/feat/identity-rebased-alpha' int…
UMR1352 Jan 23, 2025
0176037
Some feat/ts-move-calls extensions (#1509)
chrisgitiota Jan 23, 2025
9e9b28f
Feat/ts move calls ext (#1511)
chrisgitiota Jan 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/rust/sccache/setup-sccache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ runs:
if: inputs.os == 'macos-latest'
shell: bash
run: |
brew update --preinstall
brew update --auto-update
brew install sccache
- name: Install sccache (ubuntu-24.04)
Expand Down
1 change: 1 addition & 0 deletions bindings/wasm/iota_interaction_ts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
anyhow = "1.0.75"
async-trait = { version = "0.1", default-features = false }
bcs = "0.1.6"
bls12_381_plus = "0.8.17"
cfg-if = "1.0.0"
console_error_panic_hook = { version = "0.1" }
Expand Down
4 changes: 4 additions & 0 deletions bindings/wasm/iota_interaction_ts/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright 2020-2025 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

export * as move_calls from "./move_calls";
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2020-2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { Transaction } from "@iota/iota.js/transactions";

export function create(
inner_bytes: Uint8Array,
inner_type: string,
mutable: boolean,
transferable: boolean,
deletable: boolean,
packageId: string,
): Promise<Uint8Array> {
const tx = new Transaction();
const inner_arg = tx.pure(inner_bytes);
const mutableArg = tx.pure.bool(mutable);
const transferableArg = tx.pure.bool(transferable);
const deletableArg = tx.pure.bool(deletable);

tx.moveCall({
target: `${packageId}::asset::new_with_config`,
typeArguments: [inner_type],
arguments: [inner_arg, mutableArg, transferableArg, deletableArg],
});

return tx.build();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2020-2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { ObjectRef, Transaction } from "@iota/iota.js/transactions";

export function remove(
asset: ObjectRef,
asset_type: string,
packageId: string,
): Promise<Uint8Array> {
const tx = new Transaction();
const asset_arg = tx.objectRef(asset);

tx.moveCall({
target: `${packageId}::asset::delete`,
typeArguments: [asset_type],
arguments: [asset_arg],
});

return tx.build();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright 2020-2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

export * from "./create";
export * from "./delete";
export * from "./transfer";
export * from "./update";
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Copyright 2020-2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { SharedObjectRef } from "@iota/iota.js/dist/cjs/bcs/types";
import { ObjectRef, Transaction } from "@iota/iota.js/transactions";

export function transfer(
asset: ObjectRef,
assetType: string,
recipient: string,
packageId: string,
): Promise<Uint8Array> {
const tx = new Transaction();
const assetArg = tx.objectRef(asset);
const recipientArg = tx.pure.address(recipient);

tx.moveCall({
target: `${packageId}::asset::transfer`,
typeArguments: [assetType],
arguments: [assetArg, recipientArg],
});

return tx.build();
}

function makeTx(
proposal: SharedObjectRef,
cap: ObjectRef,
asset: ObjectRef,
assetType: string,
packageId: string,
functionName: string,
): Promise<Uint8Array> {
const tx = new Transaction();
const proposalArg = tx.sharedObjectRef(proposal);
const capArg = tx.objectRef(cap);
const assetArg = tx.objectRef(asset);

tx.moveCall({
target: `${packageId}::asset::${functionName}`,
typeArguments: [assetType],
arguments: [proposalArg, capArg, assetArg],
});

return tx.build();
}

export function acceptProposal(
proposal: SharedObjectRef,
recipientCap: ObjectRef,
asset: ObjectRef,
assetType: string,
packageId: string,
): Promise<Uint8Array> {
return makeTx(
proposal,
recipientCap,
asset,
assetType,
packageId,
"accept",
);
}

export function concludeOrCancel(
proposal: SharedObjectRef,
senderCap: ObjectRef,
asset: ObjectRef,
assetType: string,
packageId: string,
): Promise<Uint8Array> {
return makeTx(
proposal,
senderCap,
asset,
assetType,
packageId,
"conclude_or_cancel",
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2020-2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { ObjectRef, Transaction } from "@iota/iota.js/transactions";

export function update(
asset: ObjectRef,
content: Uint8Array,
contentType: string,
packageId: string,
): Promise<Uint8Array> {
const tx = new Transaction();
const contentArg = tx.pure(content);
const assetArg = tx.objectRef(asset);

tx.moveCall({
target: `${packageId}::asset::update`,
typeArguments: [contentType],
arguments: [assetArg, contentArg],
});

return tx.build();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
// Copyright 2020-2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { SharedObjectRef } from "@iota/iota.js/dist/cjs/bcs/types";
import { IotaObjectData } from "@iota/iota.js/dist/cjs/client";
import { ObjectRef, Transaction, TransactionArgument } from "@iota/iota.js/transactions";
import { getControllerDelegation, putBackDelegationToken } from "../utils";

export function proposeBorrow(
identity: SharedObjectRef,
capability: ObjectRef,
objects: string[],
packageId: string,
expiration?: number,
): Promise<Uint8Array> {
const tx = new Transaction();
const cap = tx.objectRef(capability);
const [delegationToken, borrow] = getControllerDelegation(tx, cap, packageId);
const identityArg = tx.sharedObjectRef(identity);
const exp = tx.pure.option("u64", expiration);
const objectsArg = tx.pure.vector("id", objects);

tx.moveCall({
target: `${packageId}::identity::propose_borrow`,
arguments: [identityArg, delegationToken, exp, objectsArg],
});

putBackDelegationToken(tx, cap, delegationToken, borrow, packageId);

return tx.build();
}

export function executeBorrow(
identity: SharedObjectRef,
capability: ObjectRef,
proposalId: string,
objects: IotaObjectData[],
intentFn: (arg0: Transaction, arg1: Map<string, [TransactionArgument, IotaObjectData]>) => void,
packageId: string,
): Promise<Uint8Array> {
const tx = new Transaction();
const cap = tx.objectRef(capability);
const [delegationToken, borrow] = getControllerDelegation(tx, cap, packageId);
const proposal = tx.pure.id(proposalId);
const identityArg = tx.sharedObjectRef(identity);

let action = tx.moveCall({
target: `${packageId}::identity::execute_proposal`,
typeArguments: [`${packageId}::borrow_proposal::Borrow`],
arguments: [identityArg, delegationToken, proposal],
});

putBackDelegationToken(tx, cap, delegationToken, borrow, packageId);

const objectArgMap = new Map<string, [TransactionArgument, IotaObjectData]>();
for (const obj of objects) {
const recvObj = tx.receivingRef(obj);
const objArg = tx.moveCall({
target: `${packageId}::identity::execute_borrow`,
typeArguments: [obj.type!],
arguments: [identityArg, action, recvObj],
});

objectArgMap.set(obj.objectId, [objArg, obj]);
}

intentFn(tx, objectArgMap);

for (const [obj, objData] of objectArgMap.values()) {
tx.moveCall({
target: `${packageId}::borrow_proposal::put_back`,
typeArguments: [objData.type!],
arguments: [action, obj],
});
}

tx.moveCall({
target: `${packageId}::transfer_proposal::conclude_borrow`,
arguments: [action],
});

return tx.build();
}

export function createAndExecuteBorrow(
identity: SharedObjectRef,
capability: ObjectRef,
objects: IotaObjectData[],
intentFn: (arg0: Transaction, arg1: Map<string, [TransactionArgument, IotaObjectData]>) => void,
packageId: string,
expiration?: number,
): Promise<Uint8Array> {
const tx = new Transaction();
const cap = tx.objectRef(capability);
const [delegationToken, borrow] = getControllerDelegation(tx, cap, packageId);
const identityArg = tx.sharedObjectRef(identity);
const exp = tx.pure.option("u64", expiration);
const objectsArg = tx.pure.vector("id", objects.map(obj => obj.objectId));

const proposal = tx.moveCall({
target: `${packageId}::identity::propose_borrow`,
arguments: [identityArg, delegationToken, exp, objectsArg],
});

let action = tx.moveCall({
target: `${packageId}::identity::execute_proposal`,
typeArguments: [`${packageId}::borrow_proposal::Borrow`],
arguments: [identityArg, delegationToken, proposal],
});

putBackDelegationToken(tx, cap, delegationToken, borrow, packageId);

const objectArgMap = new Map<string, [TransactionArgument, IotaObjectData]>();
for (const obj of objects) {
const recvObj = tx.receivingRef(obj);
const objArg = tx.moveCall({
target: `${packageId}::identity::execute_borrow`,
typeArguments: [obj.type!],
arguments: [identityArg, action, recvObj],
});

objectArgMap.set(obj.objectId, [objArg, obj]);
}

intentFn(tx, objectArgMap);

for (const [obj, objData] of objectArgMap.values()) {
tx.moveCall({
target: `${packageId}::borrow_proposal::put_back`,
typeArguments: [objData.type!],
arguments: [action, obj],
});
}

tx.moveCall({
target: `${packageId}::transfer_proposal::conclude_borrow`,
arguments: [action],
});
return tx.build();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright 2020-2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { SharedObjectRef } from "@iota/iota.js/dist/cjs/bcs/types";
import { ObjectRef, Transaction } from "@iota/iota.js/transactions";
import { getControllerDelegation, putBackDelegationToken } from "../utils";

export function proposeConfigChange(
identity: SharedObjectRef,
controllerCap: ObjectRef,
controllersToAdd: [string, number][],
controllersToRemove: string[],
controllersToUpdate: [string, number][],
packageId: string,
expiration?: number,
threshold?: number,
): Promise<Uint8Array> {
const tx = new Transaction();
const addressesToAdd = tx.pure.vector("address", controllersToAdd.map(c => c[0]));
const vpsToAdd = tx.pure.vector("u64", controllersToAdd.map(c => c[1]));
const controllersToAddArg = tx.moveCall({
target: `${packageId}::utils::vec_map_from_keys_values`,
typeArguments: ["address", "u64"],
arguments: [addressesToAdd, vpsToAdd],
});

const idsToUpdate = tx.pure.vector("id", controllersToUpdate.map(c => c[0]));
const vpsToUpdate = tx.pure.vector("u64", controllersToUpdate.map(c => c[1]));
const controllersToUpdateArg = tx.moveCall({
target: `${packageId}::utils::vec_map_from_keys_values`,
typeArguments: ["id", "u64"],
arguments: [idsToUpdate, vpsToUpdate],
});

const identityArg = tx.sharedObjectRef(identity);
const cap = tx.objectRef(controllerCap);
const [delegationToken, borrow] = getControllerDelegation(tx, cap, packageId);
const thresholdArg = tx.pure.option("u64", threshold);
const exp = tx.pure.option("u64", expiration);
const controllersToRemoveArg = tx.pure.vector("id", controllersToRemove);

tx.moveCall({
target: `${packageId}::identity::propose_config_change`,
arguments: [identityArg, delegationToken, exp, thresholdArg, controllersToAddArg, controllersToRemoveArg,
controllersToUpdateArg],
});

putBackDelegationToken(tx, cap, delegationToken, borrow, packageId);

return tx.build();
}

export function executeConfigChange(
identity: SharedObjectRef,
capability: ObjectRef,
proposalId: string,
packageId: string,
): Promise<Uint8Array> {
const tx = new Transaction();
const cap = tx.objectRef(capability);
const [delegationToken, borrow] = getControllerDelegation(tx, cap, packageId);
const proposal = tx.pure.id(proposalId);
const identityArg = tx.sharedObjectRef(identity);

tx.moveCall({
target: `${packageId}::identity::execute_config_change`,
arguments: [identityArg, delegationToken, proposal],
});

putBackDelegationToken(tx, cap, delegationToken, borrow, packageId);

return tx.build();
}
Loading
Loading