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

v 0.14.0 release #115

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 5 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
node_modules
dist

logs
*.log
npm-debug.log*
*.tsbuildinfo

coverage

*.tgz

.env
.env.local
logs
*.log
npm-debug.log*

.idea
.vscode/*
!.vscode/settings.json
!.vscode/extensions.json
*.tgz

.DS_Store
node_modules
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ignore-scripts=true
ignore-scripts=true
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"editor.defaultFormatter": "biomejs.biome"
},
"[json]": {
"editor.defaultFormatter": "biomejs.biome"
"editor.defaultFormatter": "vscode.json-language-features"
},
"editor.codeActionsOnSave": {
"quickfix.biome": "explicit"
Expand Down
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,35 @@ It is only possible to perform sync calls within the confines of one shard.

=nil; provides a multi-currency mechanism. A contract can be the owner of one custom currency, and owners can freely send custom currencies to other contracts. As a result, the balance of a given contract may contain standard tokens, and several custom tokens created by other contracts.

To create a currency and withdraw it:
There is no need to create currency, it exists for each account by default. But it has no name and zero value.
To set the name of the currency for a wallet:

```ts
const hashMessage = await wallet.sendMessage({
to: MINTER_ADDRESS,
to: walletAddress,
gas: 1_000_000n,
value: 100_000_000n,
data: encodeFunctionData({
abi: MINTER_ABI,
functionName: "create",
args: [100_000_000n, walletAddress, "MY_TOKEN", walletAddress],
functionName: "setCurrenctName",
args: ["MY_TOKEN"],
}),
});

await waitTillCompleted(client, 1, hashMessage);
```

To mint 1000 tokens of the currency:

```ts
const hashMessage = await wallet.sendMessage({
to: walletAddress,
gas: 1_000_000n,
value: 100_000_000n,
data: encodeFunctionData({
abi: MINTER_ABI,
functionName: "mintCurrency",
args: [1000n],
}),
});

Expand Down
12 changes: 9 additions & 3 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.1/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.1/schema.json",
"organizeImports": {
"enabled": true
},
Expand All @@ -10,7 +10,7 @@
"correctness": {
"noUnusedImports": "error"
},
"nursery": {
"suspicious": {
"noConsole": "error"
},
"style": {
Expand Down Expand Up @@ -39,6 +39,12 @@
"lineWidth": 80
},
"files": {
"ignore": ["node_modules", "dist", "package.json", "test/coverage"]
"ignore": [
"node_modules",
"dist",
"package.json",
"test/coverage",
"vendor"
]
}
}
8 changes: 4 additions & 4 deletions examples/asyncCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ const wallet = new WalletV1({
});
const walletAddress = await wallet.getAddressHex();

// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("walletAddress", walletAddress);

await faucet.withdrawToWithRetry(walletAddress, 100_000_000n);

await wallet.selfDeploy(true);

// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("Wallet deployed successfully");

const anotherAddress = WalletV1.calculateWalletAddress({
Expand All @@ -58,8 +58,8 @@ const hash = await wallet.sendMessage({
await waitTillCompleted(client, 1, hash);

const balance = await client.getBalance(bytesToHex(anotherAddress), "latest");
// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("balance", balance);

// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("Message sent successfully");
12 changes: 6 additions & 6 deletions examples/bounce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ const anotherWallet = new WalletV1({
signer,
});

// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("walletAddress", walletAddress);
// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("anotherWallet", anotherWallet.getAddressHex());

await faucet.withdrawToWithRetry(walletAddress, 100_000_000n);
Expand All @@ -53,7 +53,7 @@ await faucet.withdrawToWithRetry(anotherWallet.getAddressHex(), 100_000_000n);
await wallet.selfDeploy(true);
await anotherWallet.selfDeploy(true);

// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("Wallet deployed successfully");

const bounceAddress = WalletV1.calculateWalletAddress({
Expand All @@ -77,13 +77,13 @@ const hash = await wallet.sendMessage({

await waitTillCompleted(client, 1, hash);

// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("bounce address", bytesToHex(bounceAddress));

const balance = await client.getBalance(bytesToHex(bounceAddress), "latest");

// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("balance", balance);

// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("Message sent successfully");
10 changes: 5 additions & 5 deletions examples/deployInternalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ const wallet = new WalletV1({
});
const walletAddress = await wallet.getAddressHex();

// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("walletAddress", walletAddress);

await faucet.withdrawToWithRetry(walletAddress, 1000000000000n);
await wallet.selfDeploy(true);

// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("Wallet deployed successfully");
// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log(await client.getCode(walletAddress, "latest"));

const abi = [
Expand Down Expand Up @@ -72,8 +72,8 @@ if (receipts.some((receipt) => !receipt.success)) {
throw new Error("Contract deployment failed");
}

// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("Another wallet deployed successfully");
const code = await client.getCode(address, "latest");
// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("code", bytesToHex(code));
6 changes: 3 additions & 3 deletions examples/deployWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const wallet = new WalletV1({
});
const walletAddress = wallet.getAddressHex();

// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("walletAddress", walletAddress);

const faucetHash = await faucet.withdrawTo(walletAddress, convertEthToWei(0.1));
Expand All @@ -43,7 +43,7 @@ await waitTillCompleted(client, 1, bytesToHex(faucetHash));
await wallet.selfDeploy(true);

const code = await client.getCode(walletAddress, "latest");
// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("code", bytesToHex(code));
// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("Wallet deployed successfully");
6 changes: 3 additions & 3 deletions examples/externalContractDeployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const deploymentMessage = externalDeploymentMessage(
chainId,
);
const addr = bytesToHex(deploymentMessage.to);
// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("walletAddress", addr);

const faucetHash = await faucet.withdrawTo(addr, convertEthToWei(0.1));
Expand All @@ -50,12 +50,12 @@ await deploymentMessage.send(client);
while (true) {
const code = await client.getCode(addr, "latest");
if (code.length > 0) {
// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("code", bytesToHex(code));
break;
}
await new Promise((resolve) => setTimeout(resolve, 1000));
}

// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("Wallet deployed successfully");
8 changes: 4 additions & 4 deletions examples/syncCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ const wallet = new WalletV1({
});
const walletAddress = await wallet.getAddressHex();

// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("walletAddress", walletAddress);

const faucetHash = await faucet.withdrawTo(walletAddress, convertEthToWei(0.1));

await waitTillCompleted(client, 1, bytesToHex(faucetHash));
await wallet.selfDeploy(true);

// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("Wallet deployed successfully");

const anotherAddress = WalletV1.calculateWalletAddress({
Expand All @@ -60,12 +60,12 @@ await wallet.syncSendMessage({
while (true) {
const balance = await client.getBalance(bytesToHex(anotherAddress), "latest");
if (balance > 0) {
// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("balance", balance);
break;
}
await new Promise((resolve) => setTimeout(resolve, 1000));
}

// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("Message sent successfully");
8 changes: 4 additions & 4 deletions examples/tokenMint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ const faucetHash = await faucet.withdrawTo(walletAddress, convertEthToWei(0.1));
await waitTillCompleted(client, 1, bytesToHex(faucetHash));

await wallet.selfDeploy(true);
// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("Wallet deployed successfully");
// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("walletAddress", walletAddress);

const hashMessage = await wallet.sendMessage({
Expand Down Expand Up @@ -74,7 +74,7 @@ await waitTillCompleted(client, 1, hashMessage2);
const n = hexToBigInt(walletAddress);

const tokens = await client.getCurrencies(walletAddress, "latest");
// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("tokens", tokens);

const anotherAddress = WalletV1.calculateWalletAddress({
Expand Down Expand Up @@ -102,5 +102,5 @@ const anotherTokens = await client.getCurrencies(
"latest",
);

// biome-ignore lint/nursery/noConsole: <explanation>
// biome-ignore lint/suspicious/noConsole: <explanation>
console.log("anotherTokens", anotherTokens);
Loading
Loading