Skip to content

Commit

Permalink
chore: Upgrade to testnet network (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdankel authored May 30, 2024
1 parent f377262 commit 8fab7e4
Show file tree
Hide file tree
Showing 12 changed files with 32,555 additions and 16,233 deletions.
48,666 changes: 32,491 additions & 16,175 deletions app/package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"@emotion/react": "^11.11.0",
"@emotion/styled": "^11.11.0",
"@fuel-ui/css": "^0.23",
"@fuels/connectors": "^0.2.2",
"@fuels/react": "^0.18.1",
"@fuels/connectors": "0.5.0",
"@fuels/react": "0.20.0",
"@mui/base": "^5.0.0-beta.2",
"@mui/icons-material": "^5.11.16",
"@mui/lab": "^5.0.0-alpha.46",
Expand All @@ -17,7 +17,7 @@
"ace-builds": "^1.22.0",
"ace-mode-solidity": "^0.1.1",
"ansicolor": "^1.1.100",
"fuels": "^0.79",
"fuels": "0.88.1",
"react": "^18.2.0",
"react-ace": "^10.1.0",
"react-dom": "^18.2.0",
Expand Down
5 changes: 2 additions & 3 deletions app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useState } from 'react';
import { useCallback, useEffect, useState } from 'react';
import ActionToolbar from './features/toolbar/components/ActionToolbar';
import LogView from './features/editor/components/LogView';
import { useCompile } from './features/editor/hooks/useCompile';
Expand Down Expand Up @@ -48,7 +48,7 @@ function App() {
const [isCompiled, setIsCompiled] = useState(false);

// The toolchain to use for compilation.
const [toolchain, setToolchain] = useState<Toolchain>('beta-5');
const [toolchain, setToolchain] = useState<Toolchain>('testnet');

// The deployment state
const [deployState, setDeployState] = useState(DeployState.NOT_DEPLOYED);
Expand Down Expand Up @@ -120,7 +120,6 @@ function App() {
});
if (!!response) {
const permalink = `${window.location.origin}/?toolchain=${toolchain}&transpile=${showSolidity}&gist=${response.id}`;
console.log('permalink: ', permalink);
updateLog([
<Copyable
href
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/Providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function Providers({ children }: ProvidersProps) {
<QueryClientProvider client={queryClient}>
<FuelProvider
fuelConfig={{
connectors: defaultConnectors(),
connectors: defaultConnectors({ devMode: true }),
}}>
{globalCss()()}
{children}
Expand Down
1 change: 1 addition & 0 deletions app/src/features/editor/components/ToolchainDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import FormControl from '@mui/material/FormControl';
import InputLabel from '@mui/material/InputLabel/InputLabel';

const ToolchainNames = [
'testnet',
'beta-5',
'beta-4',
'beta-3',
Expand Down
2 changes: 1 addition & 1 deletion app/src/features/editor/examples/examples.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe(`test examples`, () => {
method: 'POST',
body: JSON.stringify({
contract: code,
toolchain: 'beta-5'
toolchain: 'testnet'
}),
});

Expand Down
53 changes: 32 additions & 21 deletions app/src/features/editor/examples/sway/multiasset.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
export const EXAMPLE_SWAY_CONTRACT_MULTIASSET = `// ERC1155 equivalent in Sway.
contract;
use src5::{SRC5, State, AccessError};
use src20::SRC20;
use src3::SRC3;
use standards::src5::{AccessError, SRC5, State};
use standards::src20::SRC20;
use standards::src3::SRC3;
use std::{
asset::{
burn,
mint_to,
},
call_frames::{
contract_id,
msg_asset_id,
},
call_frames::msg_asset_id,
context::this_balance,
hash::{
Hash,
},
context::this_balance,
storage::storage_string::*,
string::String
string::String,
};
storage {
Expand All @@ -33,7 +30,7 @@ storage {
abi MultiAsset {
#[storage(read, write)]
fn constructor(owner_: Identity);
#[storage(read, write)]
fn set_name(asset: AssetId, name: String);
Expand All @@ -47,10 +44,15 @@ abi MultiAsset {
impl MultiAsset for Contract {
#[storage(read, write)]
fn constructor(owner_: Identity) {
require(storage.owner.read() == State::Uninitialized, "owner-initialized");
require(
storage
.owner
.read() == State::Uninitialized,
"owner-initialized",
);
storage.owner.write(State::Initialized(owner_));
}
#[storage(read, write)]
fn set_name(asset: AssetId, name: String) {
require_access_owner();
Expand All @@ -75,7 +77,9 @@ impl MultiAsset for Contract {
#[storage(read)]
fn require_access_owner() {
require(
storage.owner.read() == State::Initialized(msg_sender().unwrap()),
storage
.owner
.read() == State::Initialized(msg_sender().unwrap()),
AccessError::NotOwner,
);
}
Expand All @@ -95,7 +99,7 @@ impl SRC20 for Contract {
fn name(asset: AssetId) -> Option<String> {
storage.name.get(asset).read_slice()
}
#[storage(read)]
fn symbol(asset: AssetId) -> Option<String> {
storage.symbol.get(asset).read_slice()
Expand All @@ -111,25 +115,32 @@ impl SRC3 for Contract {
#[storage(read, write)]
fn mint(recipient: Identity, sub_id: SubId, amount: u64) {
require_access_owner();
let asset_id = AssetId::new(contract_id(), sub_id);
let asset_id = AssetId::new(ContractId::this(), sub_id);
let supply = storage.total_supply.get(asset_id).try_read();
if supply.is_none() {
storage.total_assets.write(storage.total_assets.try_read().unwrap_or(0) + 1);
storage
.total_assets
.write(storage.total_assets.try_read().unwrap_or(0) + 1);
}
let current_supply = supply.unwrap_or(0);
storage.total_supply.insert(asset_id, current_supply + amount);
storage
.total_supply
.insert(asset_id, current_supply + amount);
mint_to(recipient, sub_id, amount);
}
#[payable]
#[storage(read, write)]
fn burn(sub_id: SubId, amount: u64) {
require_access_owner();
let asset_id = AssetId::new(contract_id(), sub_id);
let asset_id = AssetId::new(ContractId::this(), sub_id);
require(this_balance(asset_id) >= amount, "not-enough-coins");
let supply = storage.total_supply.get(asset_id).try_read();
let current_supply = supply.unwrap_or(0);
storage.total_supply.insert(asset_id, current_supply - amount);
storage
.total_supply
.insert(asset_id, current_supply - amount);
burn(sub_id, amount);
}
}
Expand Down
23 changes: 15 additions & 8 deletions app/src/features/editor/examples/sway/singleasset.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
export const EXAMPLE_SWAY_CONTRACT_SINGLEASSET = `// ERC20 equivalent in Sway.
contract;
use src3::SRC3;
use src5::{SRC5, State, AccessError};
use src20::SRC20;
use standards::src3::SRC3;
use standards::src5::{AccessError, SRC5, State};
use standards::src20::SRC20;
use std::{
asset::{
burn,
mint_to,
},
call_frames::{
contract_id,
msg_asset_id,
},
constants::DEFAULT_SUB_ID,
Expand All @@ -31,7 +30,6 @@ configurable {
storage {
total_supply: u64 = 0,
owner: State = State::Uninitialized,
}
Expand Down Expand Up @@ -81,15 +79,22 @@ impl SRC20 for Contract {
#[storage(read)]
fn require_access_owner() {
require(
storage.owner.read() == State::Initialized(msg_sender().unwrap()),
storage
.owner
.read() == State::Initialized(msg_sender().unwrap()),
AccessError::NotOwner,
);
}
impl SingleAsset for Contract {
#[storage(read, write)]
fn constructor(owner_: Identity) {
require(storage.owner.read() == State::Uninitialized, "owner-initialized");
require(
storage
.owner
.read() == State::Uninitialized,
"owner-initialized",
);
storage.owner.write(State::Initialized(owner_));
}
}
Expand All @@ -113,6 +118,7 @@ impl SRC3 for Contract {
mint_to(recipient, DEFAULT_SUB_ID, amount);
}
#[payable]
#[storage(read, write)]
fn burn(sub_id: SubId, amount: u64) {
require(sub_id == DEFAULT_SUB_ID, "incorrect-sub-id");
Expand All @@ -128,4 +134,5 @@ impl SRC3 for Contract {
.write(storage.total_supply.read() - amount);
burn(DEFAULT_SUB_ID, amount);
}
}`;
}
`;
3 changes: 2 additions & 1 deletion deployment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ RUN fuelup toolchain install beta-2
RUN fuelup toolchain install beta-3
RUN fuelup toolchain install beta-4
RUN fuelup toolchain install beta-5
RUN fuelup toolchain install testnet

# Install the forc dependencies
RUN fuelup default beta-5
RUN fuelup default testnet
RUN forc build --path projects/swaypad

EXPOSE 8080
Expand Down
22 changes: 5 additions & 17 deletions projects/swaypad/Forc.lock
Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
[[package]]
name = "core"
source = "path+from-root-B672DC9E3D340CD2"
source = "path+from-root-148AAAB4460F1A9D"

[[package]]
name = "src20"
source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.3.3#4198b4b07449ad16104cc8a0501f3013670fdcfd"
dependencies = ["std"]

[[package]]
name = "src3"
source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.3.3#4198b4b07449ad16104cc8a0501f3013670fdcfd"
dependencies = ["std"]

[[package]]
name = "src5"
source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.3.3#4198b4b07449ad16104cc8a0501f3013670fdcfd"
name = "standards"
source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.4.4#a001d3c248595112aae67e5633a06ef9bc0536ae"
dependencies = ["std"]

[[package]]
name = "std"
source = "git+https://github.com/fuellabs/sway?tag=v0.49.2#a70c746d27b3300beef896ccd1dcce1299836192"
source = "git+https://github.com/fuellabs/sway?tag=v0.59.0#d9985d8111f94235edba9a08fc71a9513ec2a95c"
dependencies = ["core"]

[[package]]
name = "swaypad"
source = "member"
dependencies = [
"src20",
"src3",
"src5",
"standards",
"std",
]
4 changes: 1 addition & 3 deletions projects/swaypad/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ license = "Apache-2.0"
name = "swaypad"

[dependencies]
src3 = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.3.3" }
src5 = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.3.3" }
src20 = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.3.3" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.4" }
1 change: 1 addition & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub enum Toolchain {
Beta1,
Latest,
Nightly,
Testnet,
}

impl fmt::Display for Toolchain {
Expand Down

0 comments on commit 8fab7e4

Please sign in to comment.