Skip to content

Commit

Permalink
normalize casing in ts code
Browse files Browse the repository at this point in the history
  • Loading branch information
UMR1352 committed Jan 22, 2025
1 parent 01d85b9 commit e7cc1ff
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 84 deletions.
12 changes: 6 additions & 6 deletions bindings/wasm/iota_interaction_ts/lib/move_calls/asset/create.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright 2020-2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { Transaction, TransactionArgument } from "@iota/iota-sdk/transactions";
import { Transaction } from "@iota/iota-sdk/transactions";

export function new_(
export function create(
inner_bytes: Uint8Array,
inner_type: string,
mutable: boolean,
Expand All @@ -13,14 +13,14 @@ export function new_(
): Promise<Uint8Array> {
const tx = new Transaction();
const inner_arg = tx.pure(inner_bytes);
const mutable_arg = tx.pure.bool(mutable);
const transferable_arg = tx.pure.bool(transferable);
const deletable_arg = tx.pure.bool(deletable);
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, mutable_arg, transferable_arg, deletable_arg],
arguments: [inner_arg, mutableArg, transferableArg, deletableArg],
});

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

import { ObjectRef, Transaction, TransactionArgument } from "@iota/iota-sdk/transactions";
import { ObjectRef, Transaction } from "@iota/iota-sdk/transactions";

export function delete_(
export function remove(
asset: ObjectRef,
asset_type: string,
packageId: string,
Expand Down
50 changes: 25 additions & 25 deletions bindings/wasm/iota_interaction_ts/lib/move_calls/asset/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,78 @@
// SPDX-License-Identifier: Apache-2.0

import { SharedObjectRef } from "@iota/iota-sdk/dist/cjs/bcs/types";
import { ObjectRef, Transaction, TransactionArgument } from "@iota/iota-sdk/transactions";
import { ObjectRef, Transaction } from "@iota/iota-sdk/transactions";

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

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

return tx.build();
}

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

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

return tx.build();
}

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

export function concludeOrCancel(
proposal: SharedObjectRef,
sender_cap: ObjectRef,
senderCap: ObjectRef,
asset: ObjectRef,
asset_type: string,
assetType: string,
packageId: string,
): Promise<Uint8Array> {
return make_tx(
return makeTx(
proposal,
sender_cap,
senderCap,
asset,
asset_type,
assetType,
packageId,
"conclude_or_cancel",
);
Expand Down
10 changes: 5 additions & 5 deletions bindings/wasm/iota_interaction_ts/lib/move_calls/asset/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import { ObjectRef, Transaction } from "@iota/iota-sdk/transactions";
export function update(
asset: ObjectRef,
content: Uint8Array,
content_type: string,
contentType: string,
packageId: string,
): Promise<Uint8Array> {
const tx = new Transaction();
const content_arg = tx.pure(content);
const asset_arg = tx.objectRef(asset);
const contentArg = tx.pure(content);
const assetArg = tx.objectRef(asset);

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

return tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export function proposeBorrow(
const [delegationToken, borrow] = getControllerDelegation(tx, cap, packageId);
const identityArg = tx.sharedObjectRef(identity);
const exp = tx.pure.option("u64", expiration);
const objects_arg = tx.pure.vector("id", objects);
const objectsArg = tx.pure.vector("id", objects);

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

putBackDelegationToken(tx, cap, delegationToken, borrow, packageId);
Expand Down Expand Up @@ -52,24 +52,24 @@ export function executeBorrow(

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

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

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

intentFn(tx, object_arg_map);
intentFn(tx, objectArgMap);

for (const [obj, obj_data] of object_arg_map.values()) {
for (const [obj, objData] of objectArgMap.values()) {
tx.moveCall({
target: `${packageId}::borrow_proposal::put_back`,
typeArguments: [obj_data.type!],
typeArguments: [objData.type!],
arguments: [action, obj],
});
}
Expand All @@ -95,11 +95,11 @@ export function createAndExecuteBorrow(
const [delegationToken, borrow] = getControllerDelegation(tx, cap, packageId);
const identityArg = tx.sharedObjectRef(identity);
const exp = tx.pure.option("u64", expiration);
const objects_arg = tx.pure.vector("id", objects.map(obj => obj.objectId));
const objectsArg = tx.pure.vector("id", objects.map(obj => obj.objectId));

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

let action = tx.moveCall({
Expand All @@ -110,24 +110,24 @@ export function createAndExecuteBorrow(

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

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

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

intentFn(tx, object_arg_map);
intentFn(tx, objectArgMap);

for (const [obj, obj_data] of object_arg_map.values()) {
for (const [obj, objData] of objectArgMap.values()) {
tx.moveCall({
target: `${packageId}::borrow_proposal::put_back`,
typeArguments: [obj_data.type!],
typeArguments: [objData.type!],
arguments: [action, obj],
});
}
Expand Down
24 changes: 12 additions & 12 deletions bindings/wasm/iota_interaction_ts/lib/move_calls/identity/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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

export function proposeConfigChange(
identity: SharedObjectRef,
Expand All @@ -16,33 +16,33 @@ export function proposeConfigChange(
threshold?: number,
): Promise<Uint8Array> {
const tx = new Transaction();
const addresses_to_add = tx.pure.vector("address", controllersToAdd.map(c => c[0]));
const vps_to_add = tx.pure.vector("u64", controllersToAdd.map(c => c[1]));
const controllers_to_add = tx.moveCall({
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: [addresses_to_add, vps_to_add],
arguments: [addressesToAdd, vpsToAdd],
});

const ids_to_update = tx.pure.vector("id", controllersToUpdate.map(c => c[0]));
const vps_to_update = tx.pure.vector("u64", controllersToUpdate.map(c => c[1]));
const controllers_to_update = tx.moveCall({
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: [ids_to_update, vps_to_update],
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 controllers_to_remove = tx.pure.vector("id", controllersToRemove);
const controllersToRemoveArg = tx.pure.vector("id", controllersToRemove);

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

putBackDelegationToken(tx, cap, delegationToken, borrow, packageId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ export function proposeControllerExecution(
const [delegationToken, borrow] = getControllerDelegation(tx, cap, packageId);
const identityArg = tx.sharedObjectRef(identity);
const exp = tx.pure.option("u64", expiration);
const controller_cap_id = tx.pure.id(controllerCapId);
const controllerCapIdArg = tx.pure.id(controllerCapId);

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

putBackDelegationToken(tx, cap, delegationToken, borrow, packageId);
Expand Down Expand Up @@ -52,16 +52,16 @@ export function executeControllerExecution(
putBackDelegationToken(tx, cap, delegationToken, borrow, packageId);

const receiving = tx.receivingRef(controllerCapRef);
const borrowed_controller_cap = tx.moveCall({
const BorrowedControllerCap = tx.moveCall({
target: `${packageId}::identity::borrow_controller_cap`,
arguments: [identityArg, action, receiving],
});

intentFn(tx, borrowed_controller_cap);
intentFn(tx, BorrowedControllerCap);

tx.moveCall({
target: `${packageId}::controller_proposal::put_back`,
arguments: [action, borrowed_controller_cap],
arguments: [action, BorrowedControllerCap],
});

return tx.build();
Expand Down Expand Up @@ -96,16 +96,16 @@ export function createAndExecuteControllerExecution(
putBackDelegationToken(tx, cap, delegationToken, borrow, packageId);

const receiving = tx.receivingRef(controllerCapRef);
const borrowed_controller_cap = tx.moveCall({
const borrowedControllerCap = tx.moveCall({
target: `${packageId}::identity::borrow_controller_cap`,
arguments: [identityArg, action, receiving],
});

intentFn(tx, borrowed_controller_cap);
intentFn(tx, borrowedControllerCap);

tx.moveCall({
target: `${packageId}::controller_proposal::put_back`,
arguments: [action, borrowed_controller_cap],
arguments: [action, borrowedControllerCap],
});

return tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { Transaction } from "@iota/iota-sdk/transactions";
import { getClockRef } from "../utils";

export function new_(didDoc: Uint8Array, packageId: string): Promise<Uint8Array> {
export function create(didDoc: Uint8Array, packageId: string): Promise<Uint8Array> {
const tx = new Transaction();
const didDocArg = tx.pure.vector("u8", didDoc);
const clock = getClockRef(tx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ export function executeSend(

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

for (const [obj, obj_type] of objects) {
for (const [obj, objType] of objects) {
const recv_obj = tx.receivingRef(obj);
tx.moveCall({
target: `${packageId}::identity::execute_send`,
typeArguments: [obj_type],
typeArguments: [objType],
arguments: [identityArg, action, recv_obj],
});
}
Expand Down
Loading

0 comments on commit e7cc1ff

Please sign in to comment.