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

Mahmoud/eng 3111 integrate with stacks raw hex signing on extension #652

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d3d7da9
init tx hex handling
m-aboelenein Nov 2, 2023
9a299ef
Merge branch 'develop' into mahmoud/eng-3111-integrate-with-stacks-ra…
m-aboelenein Nov 9, 2023
3c4dbce
added stx hex tx signing support
m-aboelenein Nov 9, 2023
ce32d7b
Merge branch 'develop' into mahmoud/eng-3111-integrate-with-stacks-ra…
m-aboelenein Nov 15, 2023
257853a
integrate with connect core utils
m-aboelenein Nov 16, 2023
c236db2
fix stx tx serialization
m-aboelenein Nov 16, 2023
7d7ec42
handle sign-hex for dapp interactions
m-aboelenein Nov 16, 2023
18051f4
update core version
m-aboelenein Nov 16, 2023
308588b
add auh to tx-creation
m-aboelenein Nov 17, 2023
2250045
Merge remote-tracking branch 'origin/develop' into mahmoud/eng-3111-i…
m-aboelenein Nov 22, 2023
4fcd9f6
Merge remote-tracking branch 'origin/develop' into mahmoud/eng-3111-i…
m-aboelenein Nov 22, 2023
d596b0d
Merge remote-tracking branch 'refs/remotes/origin/develop'
m-aboelenein Nov 30, 2023
156fd64
fix pending txs handling
m-aboelenein Nov 30, 2023
a5103b2
fix type issues
m-aboelenein Dec 1, 2023
4171497
Merge remote-tracking branch 'origin/develop' into mahmoud/eng-3111-i…
m-aboelenein Dec 4, 2023
fef354f
update core version
m-aboelenein Dec 4, 2023
0d0a5c4
Merge remote-tracking branch 'origin/develop' into mahmoud/eng-3111-i…
m-aboelenein Dec 18, 2023
d3d8657
revert removing signMultipleTransactions
m-aboelenein Dec 18, 2023
38b5a92
update core version
m-aboelenein Dec 18, 2023
06b05aa
Merge remote-tracking branch 'origin/develop' into mahmoud/eng-3111-i…
m-aboelenein Dec 20, 2023
5e33c8d
remove unused package aliases
m-aboelenein Dec 27, 2023
45d9f63
Tim/eng 3475 nonce not updating correctly after switching accounts (#…
teebszet Dec 27, 2023
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
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* eslint-disable no-nested-ternary */
import { StoreState } from '@stores/index';
import { useSelector } from 'react-redux';
import {
addressToString,
FungibleConditionCode,
NonFungibleConditionCode,
PostCondition,
} from '@stacks/transactions';
import { StoreState } from '@stores/index';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';

import TransferAmountComponent from '@components/transferAmountComponent';
import { getNameFromPostCondition, getSymbolFromPostCondition } from './helper';
Expand Down Expand Up @@ -36,9 +36,9 @@ function PostConditionsView({ postCondition, amount, icon }: Props) {
return t('TRANSFER_LESS');
case FungibleConditionCode.LessEqual:
return t('TRANSFER_LESS_EQUAL');
case NonFungibleConditionCode.DoesNotOwn:
case NonFungibleConditionCode.Sends:
return t('TRANSFER_DOES_NOT_OWN');
case NonFungibleConditionCode.Owns:
case NonFungibleConditionCode.DoesNotSend:
return t('TRANSFER_OWN');
default:
return '';
Expand Down
11 changes: 6 additions & 5 deletions src/app/screens/confirmStxTransaction/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import IconStacks from '@assets/img/dashboard/stack_icon.svg';
import { ConfirmStxTransactionState,LedgerTransactionType } from '@common/types/ledger';
import { ConfirmStxTransactionState, LedgerTransactionType } from '@common/types/ledger';
import AccountHeaderComponent from '@components/accountHeader';
import ConfirmStxTransactionComponent from '@components/confirmStxTransactionComponent';
import TransferMemoView from '@components/confirmStxTransactionComponent/transferMemoView';
Expand All @@ -16,19 +16,20 @@ import useWalletSelector from '@hooks/useWalletSelector';
import {
addressToString,
broadcastSignedTransaction,
buf2hex,
getStxFiatEquivalent,
isMultiSig,
microstacksToStx,
StacksTransaction,
TokenTransferPayload,
buf2hex,
} from '@secretkeylabs/xverse-core';
import { deserializeTransaction,MultiSigSpendingCondition } from '@stacks/transactions';
import { deserializeTransaction, MultiSigSpendingCondition } from '@stacks/transactions';
import { useMutation } from '@tanstack/react-query';
import { isLedgerAccount } from '@utils/helper';
import BigNumber from 'bignumber.js';
import { useEffect,useState } from 'react';
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useLocation,useNavigate } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom';
import styled from 'styled-components';

const AlertContainer = styled.div((props) => ({
Expand Down
8 changes: 4 additions & 4 deletions src/inpage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ declare global {
}

// we inject these in case implementors call the default providers
window.StacksProvider = StacksMethodsProvider;
window.BitcoinProvider = SatsMethodsProvider;
window.StacksProvider = StacksMethodsProvider as StacksProvider;
window.BitcoinProvider = SatsMethodsProvider as BitcoinProvider;

// We also inject the providers in an Xverse object in order to have them exclusively available for Xverse wallet
// and not clash with providers from other wallets
window.XverseProviders = {
StacksProvider: StacksMethodsProvider,
BitcoinProvider: SatsMethodsProvider,
StacksProvider: StacksMethodsProvider as StacksProvider,
BitcoinProvider: SatsMethodsProvider as BitcoinProvider,
};
2 changes: 1 addition & 1 deletion src/inpage/sats.inpage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const isValidEvent = (event: MessageEvent, method: SatsConnectMessageToContentSc
return correctSource && correctMethod && !!data.payload;
};

const SatsMethodsProvider: BitcoinProvider = {
const SatsMethodsProvider: Partial<BitcoinProvider> = {
Copy link
Member

@teebszet teebszet Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious what was the reasoning for Partial here? πŸ˜„

do we want to hide type errors when we forget to add a new method from sats-connect? πŸ€”

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my case, the version of sats-connect that we had in package.json was ahead of what was merged in develop at the time we might not want to keep it though, it's necessary now so the build doesn't fail

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I see. I'd be keen to remove it before merge, since it was a good code hint before

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m-aboelenein did you have a chance to follow up on this one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch i reverted that change πŸ‘

connect: async (btcAddressRequest): Promise<GetAddressResponse> => {
const event = new CustomEvent<GetAddressRequestEventDetails>(DomEventName.getAddressRequest, {
detail: { btcAddressRequest },
Expand Down
4 changes: 2 additions & 2 deletions src/inpage/stacks.inpage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { StacksProvider } from '@stacks/connect';
import {
AuthenticationRequestEventDetails,
DomEventName,
Expand All @@ -13,6 +12,7 @@ import {
SignatureResponseMessage,
TransactionResponseMessage,
} from '@common/types/message-types';
import { StacksProvider } from '@stacks/connect';

declare const VERSION: string;
type CallableMethods = keyof typeof ExternalMethods;
Expand Down Expand Up @@ -60,7 +60,7 @@ const isValidEvent = (event: MessageEvent, method: LegacyMessageToContentScript[
return correctSource && correctMethod && !!data.payload;
};

const StacksMethodsProvider: StacksProvider = {
const StacksMethodsProvider: Partial<StacksProvider> = {
getURL: async () => {
const { url } = await callAndReceive('getURL');
return url;
Expand Down