Skip to content

Commit

Permalink
v1.17.16
Browse files Browse the repository at this point in the history
  • Loading branch information
mytonwalletorg committed Jan 24, 2024
1 parent 1bb7198 commit e41fc4b
Show file tree
Hide file tree
Showing 28 changed files with 733 additions and 567 deletions.
1 change: 1 addition & 0 deletions changelogs/1.17.16.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bug fixes
20 changes: 20 additions & 0 deletions mobile/plugins/native-bottom-sheet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ npx cap sync
* [`prepare()`](#prepare)
* [`applyScrollPatch()`](#applyscrollpatch)
* [`clearScrollPatch()`](#clearscrollpatch)
* [`disable()`](#disable)
* [`enable()`](#enable)
* [`delegate(...)`](#delegate)
* [`release(...)`](#release)
* [`openSelf(...)`](#openself)
Expand Down Expand Up @@ -60,6 +62,24 @@ clearScrollPatch() => Promise<void>
--------------------


### disable()

```typescript
disable() => Promise<void>
```

--------------------


### enable()

```typescript
enable() => Promise<void>
```

--------------------


### delegate(...)

```typescript
Expand Down
20 changes: 20 additions & 0 deletions mobile/plugins/native-bottom-sheet/dist/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@
"complexTypes": [],
"slug": "clearscrollpatch"
},
{
"name": "disable",
"signature": "() => Promise<void>",
"parameters": [],
"returns": "Promise<void>",
"tags": [],
"docs": "",
"complexTypes": [],
"slug": "disable"
},
{
"name": "enable",
"signature": "() => Promise<void>",
"parameters": [],
"returns": "Promise<void>",
"tags": [],
"docs": "",
"complexTypes": [],
"slug": "enable"
},
{
"name": "delegate",
"signature": "(options: { key: BottomSheetKeys; globalJson: string; }) => Promise<void>",
Expand Down
2 changes: 2 additions & 0 deletions mobile/plugins/native-bottom-sheet/dist/esm/definitions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export interface BottomSheetPlugin {
prepare(): Promise<void>;
applyScrollPatch(): Promise<void>;
clearScrollPatch(): Promise<void>;
disable(): Promise<void>;
enable(): Promise<void>;
delegate(options: {
key: BottomSheetKeys;
globalJson: string;
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@
CAP_PLUGIN_METHOD(openInMain, CAPPluginReturnPromise);
CAP_PLUGIN_METHOD(applyScrollPatch, CAPPluginReturnPromise);
CAP_PLUGIN_METHOD(clearScrollPatch, CAPPluginReturnPromise);
CAP_PLUGIN_METHOD(disable, CAPPluginReturnPromise);
CAP_PLUGIN_METHOD(enable, CAPPluginReturnPromise);
)
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,45 @@ public class BottomSheetPlugin: CAPPlugin, FloatingPanelControllerDelegate {
}
}

@objc func disable(_ call: CAPPluginCall) {
ensureLocalOrigin()
ensureDelegating()

DispatchQueue.main.async { [self] in
if let presentingVc = self.fpc.presentingViewController {
presentingVc.dismiss(animated: false) {
call.resolve()
}
} else {
call.resolve()
}
}
}

@objc func enable(_ call: CAPPluginCall) {
ensureLocalOrigin()
ensureDelegating()

DispatchQueue.main.async { [self] in
if (self.fpc.presentingViewController != nil) {
call.resolve()
return
}

if let presentedVc = self.bridge!.viewController!.presentedViewController {
presentedVc.dismiss(animated: false) {
self.bridge?.viewController?.present(self.fpc, animated: false) {
call.resolve()
}
}
} else {
self.bridge?.viewController?.present(self.fpc, animated: false) {
call.resolve()
}
}
}
}

@objc func applyScrollPatch(_ call: CAPPluginCall) {
DispatchQueue.main.async { [self] in
let topVc = bridge!.viewController!.parent!.presentingViewController as! CAPBridgeViewController
Expand Down
4 changes: 4 additions & 0 deletions mobile/plugins/native-bottom-sheet/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export interface BottomSheetPlugin {

clearScrollPatch(): Promise<void>;

disable(): Promise<void>;

enable(): Promise<void>;

delegate(options: { key: BottomSheetKeys, globalJson: string }): Promise<void>;

release(options: { key: BottomSheetKeys | '*' }): Promise<void>;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mytonwallet",
"version": "1.17.15",
"version": "1.17.16",
"description": "The most feature-rich web wallet and browser extension for TON – with support of multi-accounts, tokens (jettons), NFT, TON DNS, TON Sites, TON Proxy, and TON Magic.",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion public/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.17.15
1.17.16
9 changes: 6 additions & 3 deletions src/api/blockchains/ton/util/tonapiio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ let apiByNetwork: Record<ApiNetwork, Api<unknown>> | undefined;

function getApi(network: ApiNetwork) {
if (!apiByNetwork) {
const headers = getEnvironment().apiHeaders;
const headers = {
...getEnvironment().apiHeaders,
'Content-Type': 'application/json',
};

apiByNetwork = {
mainnet: new Api(new HttpClient({
baseUrl: TONAPIIO_MAINNET_URL,
...(headers && { baseApiParams: { headers } }),
baseApiParams: { headers },
})),
testnet: new Api(new HttpClient({
baseUrl: TONAPIIO_TESTNET_URL,
...(headers && { baseApiParams: { headers } }),
baseApiParams: { headers },
})),
};
}
Expand Down
30 changes: 29 additions & 1 deletion src/api/common/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ApiTransactionExtra } from '../blockchains/ton/types';
import type { ApiDbSseConnection } from '../db';
import type { StorageKey } from '../storages/types';
import type {
AccountIdParsed,
Expand All @@ -12,14 +13,16 @@ import type {
import { IS_EXTENSION, MAIN_ACCOUNT_ID } from '../../config';
import { buildAccountId, parseAccountId } from '../../util/account';
import { toBase64Address } from '../blockchains/ton/util/tonweb';
import { apiDb } from '../db';
import { getEnvironment } from '../environment';
import { storage } from '../storages';
import idbStorage from '../storages/idb';
import { getKnownAddresses, getScamMarkers } from './addresses';

let localCounter = 0;
const getNextLocalId = () => `${Date.now()}|${localCounter++}`;

const actualStateVersion = 8;
const actualStateVersion = 9;
let migrationEnsurePromise: Promise<void>;

export function resolveBlockchainKey(accountId: string) {
Expand Down Expand Up @@ -248,4 +251,29 @@ export async function migrateStorage(onUpdate: OnApiUpdate) {
version = 8;
await storage.setItem('stateVersion', version);
}

if (version === 8) {
if (getEnvironment().isSseSupported) {
const dapps = await storage.getItem('dapps');

if (dapps) {
const items: ApiDbSseConnection[] = [];

for (const accountDapps of Object.values(dapps) as any[]) {
for (const dapp of Object.values(accountDapps) as any[]) {
if (dapp.sse?.appClientId) {
items.push({ clientId: dapp.sse?.appClientId });
}
}
}

if (items.length) {
await apiDb.sseConnections.bulkPut(items);
}
}

version = 9;
await storage.setItem('stateVersion', version);
}
}
}
9 changes: 9 additions & 0 deletions src/api/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,25 @@ export type ApiDbNft = ApiNft & {
collectionAddress: string;
};

export type ApiDbSseConnection = {
clientId: string;
};

const DB_NANE = 'tables';

export class ApiDb extends Dexie {
nfts!: Table<ApiDbNft>;

sseConnections!: Table<ApiDbSseConnection>;

constructor() {
super(DB_NANE);
this.version(1).stores({
nfts: '[accountId+address], accountId, address, collectionAddress',
});
this.version(2).stores({
sseConnections: '&clientId',
});
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/api/tonConnect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@ export async function connect(

await openExtensionPopup(true);

onPopupUpdate({
type: 'dappLoading',
connectionType: 'connect',
});

let accountId = await getCurrentAccountOrFail();
const isConnected = await isDappConnected(accountId, origin);

Expand All @@ -122,6 +117,11 @@ export async function connect(
} | undefined;

if (!isConnected || proof) {
onPopupUpdate({
type: 'dappLoading',
connectionType: 'connect',
});

const { promiseId, promise } = createDappPromise();

const dapp = {
Expand Down
16 changes: 12 additions & 4 deletions src/api/tonConnect/sse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { logDebug, logDebugError } from '../../util/logs';
import safeExec from '../../util/safeExec';
import { getCurrentNetwork, waitLogin } from '../common/accounts';
import { bytesToHex, handleFetchErrors } from '../common/utils';
import { apiDb } from '../db';
import {
getDappsState,
getSseLastEventId,
Expand All @@ -40,14 +41,19 @@ let sseDapps: SseDapp[] = [];
export async function startSseConnection(url: string, deviceInfo: DeviceInfo): Promise<ReturnStrategy | undefined> {
const params = new URL(url).searchParams;

const ret = params.get('ret') as ReturnStrategy | null;
const ret: ReturnStrategy = params.get('ret') || 'back';
const version = Number(params.get('v') as string);
const appClientId = params.get('id') as string;

if (!params.get('r')) {
return undefined;
}

if (!ret || !params.get('r')) {
if (await apiDb.sseConnections.get(appClientId)) {
// Avoid re-processing link
return ret ?? undefined;
}

const version = Number(params.get('v') as string);
const appClientId = params.get('id') as string;
const connectRequest = JSON.parse(params.get('r') as string) as ConnectRequest;
const { origin } = await tonConnect.fetchDappMetadata(connectRequest.manifestUrl);

Expand Down Expand Up @@ -79,6 +85,8 @@ export async function startSseConnection(url: string, deviceInfo: DeviceInfo): P

await sendMessage(result, secretKey, clientId, appClientId);

await apiDb.sseConnections.put({ clientId: appClientId });

if (result.event !== 'connect_error') {
await resetupSseConnection();
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/common/TokenSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ function TokenSelector({
}, [isActive]);

const handleTokenClick = useLastCallback((selectedToken: Token) => {
searchInputRef.current?.blur();

if (isPortrait) {
onBack();
} else {
Expand Down
10 changes: 10 additions & 0 deletions src/components/main/sections/Content/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ interface StateProps {
isNftSupported: boolean;
tokensCount: number;
activeContentTab?: ContentTab;
currentTokenSlug?: string;
}

function Content({
activeContentTab,
tokensCount,
onStakedTokenClick,
isNftSupported,
currentTokenSlug,
}: OwnProps & StateProps) {
const {
selectToken,
Expand Down Expand Up @@ -126,6 +128,13 @@ function Content({
});
}, [TABS, handleSwitchTab, activeTabIndex]);

useEffect(() => {
if (currentTokenSlug !== undefined) return;

setDefaultSwapParams({ tokenInSlug: undefined, tokenOutSlug: undefined });
changeTransferToken({ tokenSlug: TON_TOKEN_SLUG });
}, [currentTokenSlug]);

const handleClickAsset = useLastCallback((slug: string) => {
selectToken({ slug });

Expand Down Expand Up @@ -221,6 +230,7 @@ export default memo(
tokensCount,
isNftSupported: !isLedger,
activeContentTab: accountState?.activeContentTab,
currentTokenSlug: accountState?.currentTokenSlug,
};
},
(global, _, stickToFirst) => stickToFirst(global.currentAccountId),
Expand Down
2 changes: 1 addition & 1 deletion src/components/receive/InvoiceModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function InvoiceModal({
const handleAmountInput = useLastCallback((stringValue?: string) => {
setHasAmountError(false);

if (stringValue === undefined) {
if (!stringValue) {
setAmount(undefined);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/staking/StakingInitial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ function StakingInitial({

const minusOneLink = (
<a href="#" onClick={handleMinusOneClick} className={styles.balanceLink}>
{formatCurrency(toDecimal(ONE_TON), symbol)}
{formatCurrency(toDecimal(-ONE_TON), symbol)}
</a>
);

Expand Down
Loading

0 comments on commit e41fc4b

Please sign in to comment.