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

feat: grape update #101

Merged
merged 9 commits into from
Aug 30, 2023
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
4 changes: 2 additions & 2 deletions examples/assets/gumball_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ mod gumball_machine {
icon_url: String
) -> (ComponentAddress, Bucket) {
let (reservation, component_address) =
Runtime::allocate_component_address(Runtime::blueprint_id());
Runtime::allocate_component_address(GumballMachine::blueprint_id());

let non_fungible_global_id = NonFungibleGlobalId::package_of_direct_caller_badge(
Runtime::blueprint_id().package_address,
GumballMachine::blueprint_id().package_address,
);
let account = Blueprint::<Account>::create_advanced(OwnerRole::Fixed(rule!(require(
non_fungible_global_id
Expand Down
Binary file modified examples/assets/gumball_machine.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/helpers/get-network-id.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RadixNetwork } from '@radixdlt/babylon-gateway-api-sdk'

export const DEFAULT_NETWORK_ID = RadixNetwork.Hammunet.toString()
export const DEFAULT_NETWORK_ID = RadixNetwork.Enkinet.toString()

export const getNetworkId = () => {
const urlParams = new URLSearchParams(window.location.search)
Expand Down
2 changes: 1 addition & 1 deletion examples/helpers/hash.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('hash', () => {
join(__dirname, '../assets/gumball_machine.wasm')
).toString('hex')
expect(hash(gumballMachineWasm).toString('hex')).toBe(
'0ee930dc59854bfdfe0d638b3f794c9983dddc7197cb01d2b6275042ddb9bf27'
'a6eab9a9bf73b2beeeabb37b57fac4f83b59528ac2e59d3a84e3c932d9d8b5c1'
)
})
})
2 changes: 1 addition & 1 deletion examples/network/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const getNetworkIdDefault = () => {
const networkId = parseInt(
urlParams.get('networkId') ||
localStorage.getItem('networkId') ||
RadixNetwork.Hammunet.toString(),
RadixNetwork.Enkinet.toString(),
10
)
return networkId
Expand Down
3 changes: 1 addition & 2 deletions examples/pools/CreatePoolCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ export const CreatePoolCard = () => {
resources: Object.values(resourceAddresses),
transactions: [
{
transactionIntentHash:
response.transaction.intent_hash_hex || '',
transactionIntentHash: response.transaction.intent_hash || '',
status: response.transaction.transaction_status,
},
],
Expand Down
2 changes: 2 additions & 0 deletions examples/rdt/rdt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const getDAppDefinitionFromLocalStorage = (): Record<string, string> => {
'account_tdx_d_16996e320lnez82q6430eunaz9l3n5fnwk6eh9avrmtmj22e7m9lvl2',
[RadixNetwork.Hammunet]:
'account_tdx_22_12xt9uxe39dxdfy9c23vn0qj7eaxs8p3fjjpkr8f48edsfvyk00ck3l',
[RadixNetwork.Enkinet]:
'account_tdx_21_168ydk240yx69yl7zdz2mzkdjc3r5p6n4gwypqsype2d6d942z0tyvx',
}
}

Expand Down
44 changes: 44 additions & 0 deletions examples/rola/helpers/derive-address-from-public-key.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import {
deriveVirtualEcdsaSecp256k1AccountAddress,
deriveVirtualEddsaEd25519AccountAddress,
deriveVirtualIdentityAddress,
} from './derive-address-from-public-key'
import { RadixNetwork } from '@radixdlt/babylon-gateway-api-sdk'

describe('deriveAddressFromPublicKey', () => {
it('should derive virtual identity address', async () => {
const output = deriveVirtualIdentityAddress(
'59c02cc1c4cc1eddd90907bb848c44ac1808d844476c1621ecf234cf3ed49c57',
RadixNetwork.Enkinet
)

const result = await output.unwrapOr(undefined)
expect(result).toEqual(
'identity_tdx_21_12t5uwv48e5j7w368r7kjmcrw3wygfh0dtssz0u5n4hkq7qawrwrzyv'
)
})

it('should derive ed25519 virtual account address', async () => {
const output = deriveVirtualEddsaEd25519AccountAddress(
'59c02cc1c4cc1eddd90907bb848c44ac1808d844476c1621ecf234cf3ed49c57',
RadixNetwork.Enkinet
)

const result = await output.unwrapOr(undefined)
expect(result).toEqual(
'account_tdx_21_1285uwv48e5j7w368r7kjmcrw3wygfh0dtssz0u5n4hkq7qawthf4kn'
)
})

it('should derive secp256k1 virtual account address', async () => {
const output = deriveVirtualEcdsaSecp256k1AccountAddress(
'02807797adba8d61024c186f438b7bd9c7e1260b6306d615c35faeef9da052e5e4',
RadixNetwork.Enkinet
)

const result = await output.unwrapOr(undefined)
expect(result).toEqual(
'account_tdx_21_168razfxd603n87nals6us3nnzet2k9tjdk5dlyh2xdjkah3duuyyr3'
)
})
})
18 changes: 10 additions & 8 deletions examples/rola/helpers/derive-address-from-public-key.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
import { RadixEngineToolkit } from '@radixdlt/radix-engine-toolkit'
import { PublicKey, RadixEngineToolkit } from '@radixdlt/radix-engine-toolkit'
import { ResultAsync, errAsync } from 'neverthrow'
import { SignedChallenge } from '../../../src'
import { Buffer } from 'buffer'

const deriveVirtualIdentityAddress = (publicKey: string, networkId: number) =>
export const deriveVirtualIdentityAddress = (
publicKey: string,
networkId: number
) =>
ResultAsync.fromPromise(
RadixEngineToolkit.Derive.virtualIdentityAddressFromPublicKey(
{ kind: 'Ed25519', publicKey: Buffer.from(publicKey, 'hex') },
new PublicKey.Ed25519(publicKey),
networkId
),
(error: any): Error => error
)

const deriveVirtualEddsaEd25519AccountAddress = (
export const deriveVirtualEddsaEd25519AccountAddress = (
publicKey: string,
networkId: number
) =>
ResultAsync.fromPromise(
RadixEngineToolkit.Derive.virtualAccountAddressFromPublicKey(
{ kind: 'Ed25519', publicKey: Buffer.from(publicKey, 'hex') },
new PublicKey.Ed25519(publicKey),
networkId
),
(error: any): Error => error
)

const deriveVirtualEcdsaSecp256k1AccountAddress = (
export const deriveVirtualEcdsaSecp256k1AccountAddress = (
publicKey: string,
networkId: number
) =>
ResultAsync.fromPromise(
RadixEngineToolkit.Derive.virtualAccountAddressFromPublicKey(
{ kind: 'Secp256k1', publicKey: Buffer.from(publicKey, 'hex') },
new PublicKey.Secp256k1(publicKey),
networkId
),
(error: any): Error => error
Expand Down
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"test:watch": "jest --watch"
},
"dependencies": {
"@radixdlt/babylon-gateway-api-sdk": "^1.0.0-fig.6",
"@radixdlt/connect-button": "0.13.3",
"@radixdlt/babylon-gateway-api-sdk": "^1.0.0-grape.1",
"@radixdlt/connect-button": "0.13.4",
"@radixdlt/wallet-sdk": "0.10.1-alpha.1",
"immer": "^10.0.2",
"lodash.isequal": "^4.5.0",
Expand All @@ -69,7 +69,7 @@
"@mui/icons-material": "^5.11.16",
"@mui/joy": "^5.0.0-alpha.76",
"@mui/material": "^5.12.1",
"@radixdlt/radix-engine-toolkit": "^0.3.0-fig.1",
"@radixdlt/radix-engine-toolkit": "0.3.0-grape.1",
"@types/elliptic": "^6.4.14",
"@types/jest": "^29.4.0",
"@types/lodash.isequal": "^4.5.6",
Expand Down
4 changes: 2 additions & 2 deletions release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module.exports = {
'next',
{
name: 'develop',
channel: 'dev-fig',
prerelease: 'dev-fig',
channel: 'dev-grape',
prerelease: 'dev-grape',
},
{
name: 'release/([a-z0-9-]+)',
Expand Down
14 changes: 10 additions & 4 deletions src/_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,20 @@ export type SendTransactionResult = ResultAsync<
transactionIntentHash: string
status: TransactionStatus
},
{ error: string; message?: string }
{
error: string
message?: string
transactionIntentHash?: string
status?: TransactionStatus
}
>

export type SendTransactionInput = {
transactionManifest: string
version: number
blobs?: string[] | undefined
message?: string | undefined
version?: number
blobs?: string[]
message?: string
onTransactionId?: (transactionId: string) => void
}

export type GatewayApi = {
Expand Down
1 change: 0 additions & 1 deletion src/data-request/data-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ export const DataRequestClient = ({
const { id } = requestItemClient.add(
isLoginRequest ? 'loginRequest' : 'dataRequest'
)

return walletClient
.request(walletDataRequest, id)
.mapErr(
Expand Down
12 changes: 6 additions & 6 deletions src/data-request/transformations/rdt-to-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export const TransformRdtDataRequestToWalletRequestInput = object({
challenge: string().optional(),
}).optional(),
personaData: object({
fullName: boolean().optional(),
phoneNumbers: NumberOfValues.optional(),
emailAddresses: NumberOfValues.optional(),
isRequestingName: boolean().optional(),
numberOfRequestedPhoneNumbers: NumberOfValues.optional(),
numberOfRequestedEmailAddresses: NumberOfValues.optional(),
reset: boolean(),
oneTime: boolean().optional(),
}).optional(),
Expand Down Expand Up @@ -114,9 +114,9 @@ const withPersonaDataRequestItem =

if (input.personaData) {
const {
fullName: isRequestingName,
phoneNumbers: numberOfRequestedPhoneNumbers,
emailAddresses: numberOfRequestedEmailAddresses,
isRequestingName,
numberOfRequestedPhoneNumbers,
numberOfRequestedEmailAddresses,
} = input.personaData

if (input.personaData?.oneTime) {
Expand Down
8 changes: 4 additions & 4 deletions src/gateway/gateway-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ export const GatewayApiClient = ({
basePath,
})

const getTransactionStatus = (transactionIntentHashHex: string) =>
const getTransactionStatus = (transactionIntentHash: string) =>
ResultAsync.fromPromise(
transaction.getStatus(transactionIntentHashHex),
transaction.getStatus(transactionIntentHash),
errorIdentity
)

const getTransactionDetails = (transactionIntentHashHex: string) =>
const getTransactionDetails = (transactionIntentHash: string) =>
ResultAsync.fromPromise(
transaction.getCommittedDetails(transactionIntentHashHex),
transaction.getCommittedDetails(transactionIntentHash),
errorIdentity
)

Expand Down
4 changes: 2 additions & 2 deletions src/gateway/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const GatewayClient = ({
logger?: AppLogger
retryConfig?: ExponentialBackoffInput
}) => {
const pollTransactionStatus = (transactionIntentHashHex: string) => {
const pollTransactionStatus = (transactionIntentHash: string) => {
const retry = ExponentialBackoff(retryConfig)

const completedTransactionStatus = new Set<TransactionStatus>([
Expand All @@ -49,7 +49,7 @@ export const GatewayClient = ({
logger?.debug(`pollingTxStatus retry #${result.value + 1}`)

return gatewayApi
.getTransactionStatus(transactionIntentHashHex)
.getTransactionStatus(transactionIntentHash)
.map((response) => {
if (completedTransactionStatus.has(response.status))
return response
Expand Down
4 changes: 2 additions & 2 deletions src/gateway/helpers/exponential-backoff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export type ExponentialBackoffInput = {
export type ExponentialBackoff = typeof ExponentialBackoff
export const ExponentialBackoff = ({
maxDelayTime = 10_000,
multiplier = 3,
multiplier = 2,
timeout,
interval = 1_000,
interval = 2_000,
}: ExponentialBackoffInput = {}) => {
const trigger = new Subject<void>()
let numberOfRetries = 0
Expand Down
Loading
Loading