Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Commit

Permalink
Merge pull request #44 from kinecosystem/attr-create
Browse files Browse the repository at this point in the history
Attributed account creations
  • Loading branch information
samdowd authored Apr 27, 2022
2 parents cffc624 + a0d251f commit 41ffd53
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 28 deletions.
2 changes: 1 addition & 1 deletion KinBase.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
Pod::Spec.new do |s|
s.name = 'KinBase'
s.version = '2.1.2'
s.version = '2.1.3'
s.summary = 'Kin SDK for iOS'

s.description = <<-DESC
Expand Down
4 changes: 2 additions & 2 deletions KinBase/KinBase.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1799,7 +1799,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.1.2;
MARKETING_VERSION = 2.1.3;
OTHER_LDFLAGS = (
"$(inherited)",
"-l\"c++\"",
Expand Down Expand Up @@ -1841,7 +1841,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.1.2;
MARKETING_VERSION = 2.1.3;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = (
"$(inherited)",
Expand Down
15 changes: 8 additions & 7 deletions KinBase/KinBase/Src/KinAccountContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ public enum AccountSpec {
public protocol KinAccountReadOperations {
/**
Returns the account info
- Parameter appIndex: set to client AppIndex to attribute account creation,
- Parameter forceUpdate: set to `true` to force an update from network
- Returns: a `Promise` containing the `KinAccount` or an error
*/
func getAccount(forceUpdate: Bool) -> Promise<KinAccount>
func getAccount(appIndex: AppIndex, forceUpdate: Bool) -> Promise<KinAccount>

/**
Returns the current balance and listens to future account balance changes.
Expand Down Expand Up @@ -273,17 +274,17 @@ public class KinAccountContext {

// MARK: KinAccountReadOperations
extension KinAccountContext: KinAccountReadOperations {
public func getAccount(forceUpdate: Bool = false) -> Promise<KinAccount> {
public func getAccount(appIndex: AppIndex = AppIndex(value: 0), forceUpdate: Bool = false) -> Promise<KinAccount> {
log.info(msg: #function)
return storage.getAccount(accountPublicKey)
.then(on: dispatchQueue) { storedAccount -> Promise<KinAccount> in
guard let account = storedAccount else {
return self.getAccountAndRecover()
}

switch account.status {
case .unregistered:
return self.registerAccount(account: account)
return self.registerAccount(account: account, appIndex: appIndex)
.then(on: self.dispatchQueue) { _ in
self.getAccountAndRecover()
}
Expand Down Expand Up @@ -587,9 +588,9 @@ extension KinAccountContext {
}
}

private func registerAccount(account: KinAccount) -> Promise<KinAccount> {
let keyPair = KeyPair(publicKey: account.publicKey, privateKey: account.privateKey!) // FIXME:
return service.createAccount(account: account.publicKey, signer: keyPair, appIndex: AppIndex(value: 0))
private func registerAccount(account: KinAccount, appIndex: AppIndex) -> Promise<KinAccount> {
let keyPair = KeyPair(publicKey: account.publicKey, privateKey: account.privateKey!)
return service.createAccount(account: account.publicKey, signer: keyPair, appIndex: appIndex)
.then(on: dispatchQueue) { registeredAccount -> KinAccount in
return account.merge(registeredAccount)
}
Expand Down
5 changes: 3 additions & 2 deletions KinBase/KinBase/Src/Network/KinService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,9 @@ extension KinServiceV4 : KinServiceType {
// Add memo if app index is provided
if let appIndex = appIndex {
let memo = try! KinBinaryMemo(typeId: KinBinaryMemo.TransferType.none.rawValue, appIdx: appIndex.value)
instructions.append(
MemoProgram.memoInsutruction(with: memo.encode().base64EncodedData())
instructions.insert(
MemoProgram.memoInsutruction(with: memo.encode().base64EncodedData()),
at: 0
)
}

Expand Down
2 changes: 1 addition & 1 deletion KinBase/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The KinBase module is the foundation upon which the rest of the SDK stands.
## Installation
Add the following to your Podfile.
```
pod 'KinBase', '~> 2.1.2'
pod 'KinBase', '~> 2.1.3'
```

## Overview
Expand Down
2 changes: 1 addition & 1 deletion KinDesign.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
Pod::Spec.new do |s|
s.name = 'KinDesign'
s.version = '2.1.2'
s.version = '2.1.3'
s.summary = 'Kin Design Library for iOS'

s.description = <<-DESC
Expand Down
4 changes: 2 additions & 2 deletions KinDesign/KinDesign.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.1.2;
MARKETING_VERSION = 2.1.3;
PRODUCT_BUNDLE_IDENTIFIER = org.kin..KinDesign;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -458,7 +458,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.1.2;
MARKETING_VERSION = 2.1.3;
PRODUCT_BUNDLE_IDENTIFIER = org.kin..KinDesign;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down
2 changes: 1 addition & 1 deletion KinDesign/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ All of these components can be tested out and browsed in the [sample app](../Kin
## Installation
Add the following to your project's Podfile.
```
pod 'KinDesign', '~> 2.1.2'
pod 'KinDesign', '~> 2.1.3'
```

### Primary Button
Expand Down
4 changes: 2 additions & 2 deletions KinSampleApp/KinSampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.1.2;
MARKETING_VERSION = 2.1.3;
PRODUCT_BUNDLE_IDENTIFIER = org.kin..KinSampleApp;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -602,7 +602,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.1.2;
MARKETING_VERSION = 2.1.3;
PRODUCT_BUNDLE_IDENTIFIER = org.kin..KinSampleApp;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
6 changes: 3 additions & 3 deletions KinUX.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
Pod::Spec.new do |s|
s.name = 'KinUX'
s.version = '2.1.2'
s.version = '2.1.3'
s.summary = 'UX Library for Kin SDK iOS'

s.description = <<-DESC
Expand All @@ -20,8 +20,8 @@ Pod::Spec.new do |s|

s.source_files = 'KinUX/KinUX/Src/**/*'

s.dependency 'KinBase', '~> 2.1.2'
s.dependency 'KinDesign', '~> 2.1.2'
s.dependency 'KinBase', '~> 2.1.3'
s.dependency 'KinDesign', '~> 2.1.3'

# Dependencies needed for KinGrpcApi
s.dependency 'gRPC-ProtoRPC'
Expand Down
4 changes: 2 additions & 2 deletions KinUX/KinUX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.1.2;
MARKETING_VERSION = 2.1.3;
PRODUCT_BUNDLE_IDENTIFIER = org.kin..KinUX;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -619,7 +619,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.1.2;
MARKETING_VERSION = 2.1.3;
PRODUCT_BUNDLE_IDENTIFIER = org.kin..KinUX;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down
2 changes: 1 addition & 1 deletion KinUX/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The KinUX module provides an easy to use out of the box spend flow UI that is pr
Add the following to your project's Podfile.
This will also transitively pull in KinBase and KinDesign into your project as well.
```
pod 'KinUX', '~> 2.1.2'
pod 'KinUX', '~> 2.1.3'
```

## Overview
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ In your Podfile

```
// If you just want to access the blockchain & no UI
pod 'KinBase', '~> 2.1.2'
pod 'KinBase', '~> 2.1.3'
// Add spend to use the modal spend flow to allow users to buy things with Kin
pod 'KinUX', '~> 2.1.2'
pod 'KinUX', '~> 2.1.3'
// Add design for direct access to UI views you can use in your own app
pod 'KinDesign', '~> 2.1.2'
pod 'KinDesign', '~> 2.1.3'
```

## Sample App
Expand Down

0 comments on commit 41ffd53

Please sign in to comment.