Skip to content

Commit

Permalink
Merge pull request #109 from blocto/develop
Browse files Browse the repository at this point in the history
Release to prod
  • Loading branch information
mordochi authored Sep 4, 2024
2 parents cd02a36 + 8ecb73c commit bf30c85
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 78 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dependencies": {
"@blocto/dappauth": "^2.1.0",
"@blocto/fcl": "^1.0.0-alpha.1",
"@blocto/sdk": "^0.10.2",
"@blocto/sdk": "0.10.3-beta.0",
"@chakra-ui/icons": "^1.1.1",
"@chakra-ui/react": "^1.7.4",
"@emotion/react": "^11",
Expand Down
8 changes: 4 additions & 4 deletions src/components/FlowEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { ReactJSXElement } from "@emotion/react/types/jsx-namespace";
import { ec as EC } from "elliptic";
import { SHA3 } from "sha3";
import * as types from "@onflow/types";
import * as Campaign from "../scripts/flow/Campaign";
import * as BloctoDAOTemplates from "../scripts/flow/DAO";
// import * as Campaign from "../scripts/flow/Campaign";
// import * as BloctoDAOTemplates from "../scripts/flow/DAO";
import * as SignMessageTemplates from "../scripts/flow/SignMessage";
import * as TransactionsTemplates from "../scripts/flow/Transactions";
import ScriptTypes, { Arg } from "../types/ScriptTypes";
Expand Down Expand Up @@ -107,8 +107,8 @@ function parseFclArgs(args: Arg[] = []) {
}

const MenuGroups = [
{ title: "Campaign", templates: Campaign },
{ title: "DAO", templates: BloctoDAOTemplates },
// { title: "Campaign", templates: Campaign },
// { title: "DAO", templates: BloctoDAOTemplates },
{ title: "Transactions", templates: TransactionsTemplates },
{ title: "Sign Message", templates: SignMessageTemplates },
];
Expand Down
83 changes: 20 additions & 63 deletions src/scripts/flow/Transactions.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
import ScriptTypes from "../../types/ScriptTypes";
import getAddress from "../../utils/getAddress";

export const getFUSDBalance = {
type: ScriptTypes.SCRIPT,
script: `
import FungibleToken from ${getAddress("FungibleToken")}
import FUSD from ${getAddress("FUSD")}
pub fun main (address: Address): UFix64 {
let vaultRef = getAccount(address).getCapability(/public/fusdBalance)!.borrow<&AnyResource{FungibleToken.Balance}>()
?? panic("Could not borrow reference to the owner's Vault!")
return vaultRef.balance
}
`,
args: [{ type: "Address", comment: "address" }],
};

export const getBLTBalance = {
type: ScriptTypes.SCRIPT,
script: `
import FungibleToken from ${getAddress("FungibleToken")}
import BloctoToken from ${getAddress("BloctoToken")}
pub fun main (address: Address): UFix64 {
let vaultRef = getAccount(address).getCapability(/public/bloctoTokenBalance)!.borrow<&AnyResource{FungibleToken.Balance}>()
access(all) fun main (address: Address): UFix64 {
let vaultRef = getAccount(address).capabilities.borrow<&{FungibleToken.Balance}>(/public/bloctoTokenBalance)
?? panic("Could not borrow reference to the owner's Vault!")
return vaultRef.balance
}
Expand All @@ -37,8 +22,8 @@ export const getTUSDTBalance = {
import FungibleToken from ${getAddress("FungibleToken")}
import TeleportedTetherToken from ${getAddress("TeleportedTetherToken")}
pub fun main (address: Address): UFix64 {
let vaultRef = getAccount(address).getCapability(TeleportedTetherToken.TokenPublicBalancePath)!.borrow<&AnyResource{FungibleToken.Balance}>()
access(all) fun main (address: Address): UFix64 {
let vaultRef = getAccount(address).capabilities.borrow<&{FungibleToken.Balance}>(TeleportedTetherToken.TokenPublicBalancePath)
?? panic("Could not borrow reference to the owner's Vault!")
return vaultRef.balance
}
Expand All @@ -52,60 +37,32 @@ export const getFlowBalance = {
import FungibleToken from ${getAddress("FungibleToken")}
import FlowToken from ${getAddress("FlowToken")}
pub fun main (address: Address): UFix64 {
let vaultRef = getAccount(address).getCapability(/public/flowTokenBalance)!.borrow<&AnyResource{FungibleToken.Balance}>()
access(all) fun main (address: Address): UFix64 {
let vaultRef = getAccount(address).capabilities.borrow<&{FungibleToken.Balance}>(/public/flowTokenBalance)
?? panic("Could not borrow reference to the owner's Vault!")
return vaultRef.balance
}
`,
args: [{ type: "Address", comment: "address" }],
};

export const sendFUSD = {
type: ScriptTypes.TX,
script: `\
import FungibleToken from ${getAddress("FungibleToken")}
import FUSD from ${getAddress("FUSD")}
transaction(amount: UFix64, to: Address) {
let sentVault: @FungibleToken.Vault
prepare(signer: AuthAccount) {
let vaultRef = signer.borrow<&FUSD.Vault>(from: /storage/fusdVault)
?? panic("Could not borrow reference to the owner's Vault!")
self.sentVault <- vaultRef.withdraw(amount: amount)
}
execute {
let recipient = getAccount(to)
let receiverRef = recipient.getCapability(/public/fusdReceiver)!.borrow<&{FungibleToken.Receiver}>()
?? panic("Could not borrow receiver reference to the recipient's Vault")
receiverRef.deposit(from: <-self.sentVault)
}
}`,
args: [
{ type: "UFix64", comment: "amount" },
{ type: "Address", comment: "recipient" },
],
shouldSign: true,
};

export const sendBLT = {
type: ScriptTypes.TX,
script: `\
import FungibleToken from ${getAddress("FungibleToken")}
import BloctoToken from ${getAddress("BloctoToken")}
transaction(amount: UFix64, to: Address) {
let sentVault: @FungibleToken.Vault
prepare(signer: AuthAccount) {
let vaultRef = signer.borrow<&BloctoToken.Vault>(from: /storage/bloctoTokenVault)
let sentVault: @{FungibleToken.Vault}
prepare(signer: auth(BorrowValue) &Account) {
let vaultRef = signer.storage.borrow<auth(FungibleToken.Withdraw) &BloctoToken.Vault>(from: /storage/bloctoTokenVault)
?? panic("Could not borrow reference to the owner's Vault!")
self.sentVault <- vaultRef.withdraw(amount: amount)
}
execute {
let recipient = getAccount(to)
let receiverRef = recipient.getCapability(/public/bloctoTokenReceiver)!.borrow<&{FungibleToken.Receiver}>()
let receiverRef = recipient.capabilities.borrow<&{FungibleToken.Receiver}>(/public/bloctoTokenReceiver)
?? panic("Could not borrow receiver reference to the recipient's Vault")
receiverRef.deposit(from: <-self.sentVault)
}
Expand All @@ -126,12 +83,12 @@ import TeleportedTetherToken from ${getAddress("TeleportedTetherToken")}
transaction(amount: UFix64, to: Address) {
// The Vault resource that holds the tokens that are being transferred
let sentVault: @FungibleToken.Vault
let sentVault: @{FungibleToken.Vault}
prepare(signer: AuthAccount) {
prepare(signer: auth(BorrowValue) &Account) {
// Get a reference to the signer's stored vault
let vaultRef = signer.borrow<&TeleportedTetherToken.Vault>(from: TeleportedTetherToken.TokenStoragePath)
let vaultRef = signer.storage.borrow<auth(FungibleToken.Withdraw) &TeleportedTetherToken.Vault>(from: TeleportedTetherToken.TokenStoragePath)
?? panic("Could not borrow reference to the owner's Vault!")
// Withdraw tokens from the signer's stored vault
Expand All @@ -144,8 +101,8 @@ transaction(amount: UFix64, to: Address) {
let recipient = getAccount(to)
// Get a reference to the recipient's Receiver
let receiverRef = recipient.getCapability(TeleportedTetherToken.TokenPublicReceiverPath)
.borrow<&{FungibleToken.Receiver}>()
let receiverRef = recipient.capabilities
.borrow<&{FungibleToken.Receiver}>(TeleportedTetherToken.TokenPublicReceiverPath)
?? panic("Could not borrow receiver reference to the recipient's Vault")
// Deposit the withdrawn tokens in the recipient's receiver
Expand All @@ -168,12 +125,12 @@ import FlowToken from ${getAddress("FlowToken")}
transaction(amount: UFix64, to: Address) {
// The Vault resource that holds the tokens that are being transferred
let sentVault: @FungibleToken.Vault
let sentVault: @{FungibleToken.Vault}
prepare(signer: AuthAccount) {
prepare(signer: auth(BorrowValue) &Account) {
// Get a reference to the signer's stored vault
let vaultRef = signer.borrow<&FlowToken.Vault>(from: /storage/flowTokenVault)
let vaultRef = signer.storage.borrow<auth(FungibleToken.Withdraw) &FlowToken.Vault>(from: /storage/flowTokenVault)
?? panic("Could not borrow reference to the owner's Vault!")
// Withdraw tokens from the signer's stored vault
Expand All @@ -186,8 +143,8 @@ transaction(amount: UFix64, to: Address) {
let recipient = getAccount(to)
// Get a reference to the recipient's Receiver
let receiverRef = recipient.getCapability(/public/flowTokenReceiver)
.borrow<&{FungibleToken.Receiver}>()
let receiverRef = recipient.capabilities
.borrow<&{FungibleToken.Receiver}>(/public/flowTokenReceiver)
?? panic("Could not borrow receiver reference to the recipient's Vault")
// Deposit the withdrawn tokens in the recipient's receiver
Expand Down
13 changes: 13 additions & 0 deletions src/services/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,19 @@ export const supportedChains = [
faucet: "https://faucet.quicknode.com/blast/sepolia",
environment: "testnet",
},
{
name: "Merlin",
chainId: "0x1068",
rpcUrls: ["https://rpc.merlinchain.io"],
environment: "mainnet",
},
{
name: "Merlin Testnet",
chainId: "0xA7B14",
rpcUrls: ["https://testnet-rpc.merlinchain.io"],
faucet: "https://coinfaucet.eu/en/btc-testnet/",
environment: "testnet",
},
];

const bloctoSDK = new BloctoSDK({
Expand Down
8 changes: 2 additions & 6 deletions src/utils/getAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ export default function getAddress(key: string): string {
return "0xe0f601b5afd47581";
case "FungibleToken":
return "0xf233dcee88fe0abe";
case "FUSD":
return "0x3c5959b568896393";
case "BloctoToken":
return "0x0f9df91c9121c460";
case "TeleportedTetherToken":
Expand All @@ -26,12 +24,10 @@ export default function getAddress(key: string): string {
return "0x7deafdfc288e422d";
case "FungibleToken":
return "0x9a0766d93b6608b7";
case "FUSD":
return "0xe223d8a629e49c68";
case "BloctoToken":
return "0x6e0797ac987005f5";
return "0x653cfe36d146e7be";
case "TeleportedTetherToken":
return "0xab26e0a07d770ec1";
return "0x2d270db9ac8c7fef";
case "BloctoPrize":
return "0xc52330593c1d935f";
default:
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1407,10 +1407,10 @@
deepmerge "^4.2.2"
sha3 "^2.1.4"

"@blocto/sdk@^0.10.2":
version "0.10.2"
resolved "https://registry.yarnpkg.com/@blocto/sdk/-/sdk-0.10.2.tgz#d29c652d25ac367a3c8d5fabdcb770b5cbb07c1c"
integrity sha512-9gCIUKA7/7/hMHaa5n94+OYU/3tHd6vmBgTgv4o2h3z9SFueQXAJMO4aBggH9+EldgHQDI6wHsnvytEt9AWb6g==
"@blocto/[email protected].3-beta.0":
version "0.10.3-beta.0"
resolved "https://registry.yarnpkg.com/@blocto/sdk/-/sdk-0.10.3-beta.0.tgz#23f46a0a3882897d023d3a8331082df3cf5c9127"
integrity sha512-lp3HAbK7xEY/FOYDAVIS510TquqWud/tMfwDPihtpJGo74ZehFgoat7C+2HgC7S5U+RcaOyDcrvihHEWDlMBRA==
dependencies:
buffer "^6.0.3"
eip1193-provider "^1.0.1"
Expand Down

0 comments on commit bf30c85

Please sign in to comment.